Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VARTYPE() vs PEMSTATUS()
Message
De
09/01/2009 10:32:22
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
 
 
À
09/01/2009 10:12:23
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01372210
Message ID:
01372355
Vues:
25
>>>>Then why all the PEMSTATUS and VARTYPE stuff if TYPE is all you need?
>>>
>>>PEMSTATUS() also lets you check whether a method exists before you call it. I use it a lot in framework code.
>>>
>>>As for VARTYPE(), we have it because we asked for it. Using TYPE() correctly is tricky--do you need quotes or not? VARTYPE() is easier and faster, though it's meant only for cases when you already know the thing exists. I use it on parameters a lot.
>>>
>>>Tamar
>>
>>This is from the help:
>>
>>VARTYPE( ) is similar to the TYPE( ) function, but VARTYPE( ) is faster and does not require quotation marks ("") 
>>to enclose the specified expression.
>>
>> They make it sound like they are interchangeable, but according to some posts here there seems to be problems in using VARTYPE in certain situations.
>
>VARTYPE() is born with many bugs,
>some are fixed, others are not fixed.
>
>But TYPE is not the universal answer:
>
>CLEAR
>
>ON ERROR ?? "ERROR: "+MESSAGE()
>test()
>DIMENSION something[3]
>something = 'blabla'
>
>? "--------- AFTER ------"
>
>test()
>
>
>PROCEDURE something
>	RETURN DATE()
>ENDPROC
>
>
>PROCEDURE test
>
>? TYPE("something()")	&& TYPE return "U" for every bad syntax
>? TYPE("1+''")			&& TYPE return "U" for every bad syntax
>? TYPE("something(2)")  && TYPE don't call UDF
>? VARTYPE(something(2)) && VARTYPE call array or UDF
>? VARTYPE(something())  && VARTYPE call UDF but an array exists the fire a error !
>ENDPROC
>
So, is there a way to have a few lines of code that could cascade conditionally and determine of a variable or an object exists reliably? That's really what I'm after. Just include the name of the var or obj and have it tell me?
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform