Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Upper() problem
Message
 
À
17/03/2000 15:36:56
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00347286
Message ID:
00347596
Vues:
23
Quinn,

Here is how strings are compared for equality in xBase;
1)   They are considered equal
2)   They are compared one character at a time
3)   The comparison stops when the string on the right is exhausted
4)   The result is returned
This provides for partial string matching which is instrumental in Fox giving you some of the features it does. For example, if you have a last name field that is 35 characters long and you want to SEEK "Smith" to find a Smith record. If strings were not compared this way you would need to;

SEEK PADR("Smith",LEN(LastName))

to pad the length to match. With the comaprison the way it is you only need to;

SEEK "Smith"

If you require exact string comparison you can use the == (double equal sign) and that will provide exact matches.

Some may say that SET EXACT ON will give you exact comparisons, but it does not. The proof is the following test;
lcVar1 = "Smith"
lcVar2 = "Smith     "
SET EXACT OFF

?lcVar2 = lcVar1 && True
?lcVar1 = lcVar2 && False
? lcVar2 == lcVar1 && False

SET EXACT ON

? lcVar2 = lcVar1 && True
? lcVar1 = lcVar2 && True
? lcVar1 == lcVar2 && False
This behavior is due to how the things work. SET EXACT ON will pad the shorter string with spaces to be equal in length with the longer and then compare them in the above mannor. The double equal sign compares the strings in the above mannor and then checks their lengths to see if they are the same.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform