Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VARTYPE() vs PEMSTATUS()
Message
De
08/01/2009 21:45:13
 
 
À
08/01/2009 20:38:10
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01372210
Message ID:
01372220
Vues:
32
This message has been marked as the solution to the initial question of the thread.
If you want to check the existance of a property use:
IF PEMSTATUS(thisform,"tmrCheckMousePosition",5)
   && Exists
ELSE
   && Does not exist
ENDIF
If you want to check for the existance of variable:
IF VARTYPE(lcMyVariable) != "U"
   && Exists
ELSE
   && Does not exist
ENDIF
Always works!

>Those two expressions are completly different, and both will crash.
>The first will crash if there is no THISFORM.tmrCheckMousePosition property, otherwise it will return .T. or .F. depending on whether >THISFORM.tmrCheckMousePosition is an object or not.
>Tthe second one returns a character string describing whether THISFORM.tmrCheckMousePosition.O is a property, Method, Event or Object, >and thus will crash. Additionally, even if you change the second one to check the return type it will still crash if the tmrCheckMousePosition >object does not exist. I assume that you intended the second expression to be
>PEMSTATUS(ThisForm, "tmrCheckMousePosition", 3) == "Object"
>
>Personally I prefer to use something like -
>Type("THISFORM.tmrCheckMousePosition.Name") == "C"
>This will never crash and also handles the case where THISFORM.tmrCheckMousePosition could be a .NULL. value of type object.
>
>Ian Simcock.
>
>
>
>The PemStatus line is wrong as what you have there will return a character string specifying i
>
>>Is there any difference between these two functions - Dragan's anticipated comments aside - or advantage of one over the other?
>>
>
>>IF VARTYPE( THISFORM.tmrCheckMousePosition ) = 'O'
>>
>>
>>IF PEMSTATUS(THISFORM.tmrCheckMousePosition,'O',3)
>>
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform