Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How Do I
Message
 
À
26/01/1999 12:47:45
Walter Meester
HoogkarspelPays-Bas
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Titre:
Divers
Thread ID:
00180248
Message ID:
00180382
Vues:
18
>George,
>
>I didn't even know there was an double ==. I just copied this from the message of Bob Archer. You're indeed correct if you say that the double equal sign is not needed in this case, but sometimes i find it correct to use the double '=' by means of readability. for eg:
>
>lRetvalue= nValue1 == nValue2
>
>instead off
>
>lRetValue= nValue1= nValue2
>
>Because in C and C++ this would be evaluated total differently
>
Hi Walter,

First, I understand perfectly. What I'm about to write is more for newcomers to VFP (and myself < g >) than you.

There's a sometimes a difference between the way VFP evaluates strings when using a single equal sign and a double equal sign. I say sometimes because it's dependent on the value returned by SET('EXACT'). If SET('EXACT') = 'ON', then there's no difference in the way the two evaluate two string expression. However, when SET('EXACT') = 'OFF' then there is.

Consider the following code snippet:
SET EXACT OFF
? 'X' = 'XX' && returns .F.
? 'XX' = 'X' && returns .T.
? 'XX' = 'XX' && returns .T.
? 'X' == 'XX' && returns .F. again
? 'XX' == 'X' && returns .F. this time
? 'XX' == 'XX' && .T., of course.
What happens is that when SET('EXACT') is equal 'OFF' if the string expression on the right of the equal contains more characters than the one on the left, the comparison only goes as far as the number of characters in the string on the left. If the string on the left contains more characters than the one on the right, then the strings are automatically unequal regardless of the number of character matches.

The double equal sign in VFP is the direct equivalent of SETting EXACT ON and then OFF again.
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform