Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using == vs =
Message
De
06/11/2015 08:27:57
Walter Meester
HoogkarspelPays-Bas
 
 
À
06/11/2015 04:56:01
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01627149
Message ID:
01627164
Vues:
67
Fernando,

I know how it works, but up until now, I've only used == in cases where it needs to be done.
I think it might be better to ALWAYS use == in any comparison, EXCEPT in cases where you want matches on partial strings

So the question is where might that go wrong.

Walter,


>>Just encountered a bug in our software releated to the use of = when set exact is set to off.
>>
>>I Know I should be using == in those cases where comparing strings of different lenght, but just a small test made me wonder.
>>
>>Is there any reason I should not use == for any comparison in VFP? It seems to work for any datatype.
>>
>>Is there any gotcha using == as a standard?
>>
>>
>>Walter,
>
>Hi Walter:
>
>- When you want to make sure you compare the exact match, then you should use "==" to make the comparison independent of the SET EXACT setting
>- When you want to compare by the alternative logic of "begins with", then you use "=" and SET EXACT OFF
>
>In regards of the velocity of comparison between "==" and "=", in my PC a 1000000 (millon) FOR loop shows me that "== is a little faster, but negligible in small loops:
>
>
>*--
>nSecs=SECONDS()
>FOR I = 1 TO 1000000
>   =("AA" = "AAA")
>ENDFOR
>? SECONDS()-nSecs
>
>0.187
>
>*--
>nSecs=SECONDS()
>FOR I = 1 TO 1000000
>   =("AA" == "AAA")
>ENDFOR
>? SECONDS()-nSecs
>
>0.140
>
>*--
>
>
>
>Regards.-
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform