Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Prevent error on type mismatch
Message
De
12/03/2011 17:55:04
Mike Yearwood
Toronto, Ontario, Canada
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01503417
Message ID:
01503490
Vues:
93
>thanks naomi - that would work as well. I think Al's solution is going to hold up.

No. It won't.

If you have a numeric field that happens to be 0.00 at the time your code fires, then you are getting a false reading. You have to be very specific with computers. If you have a text memory variable that you want to see if it is empty, and not be tricked by an exactly matching fieldname, and I argue all memory variables should be prefaced, just in cases like this, then your code needs to be...

if m.fln = " "
fln = "Temp"
endif

>
>k
>
>>>In the following command (fln refers to file name)
>>>
>>>if fln = " " 
>>>fln = "Temp"
>>>endif
>>>
>>>
>>>i get this error message
>>>
>>>Operator/operand type mismatch
>>>
>>>I cannot find the point in my programming at which this variable becomes a numeric reference - but nonetheless Is there a command line i can run immediately before to check if fln is text variable, if not then change it to a text variable before the error message comes up.
>>>
>>>thanks
>>>k
>>
>>if vartype(m.fln) = "C" && our variable is of the character type
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform