Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
AND and OR evaluations in conditional statements
Message
De
07/04/1999 13:48:03
 
 
À
07/04/1999 13:37:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00206066
Message ID:
00206069
Vues:
17
>>Does Foxpro exaluate all ANDs before any ORs in a conditional statement, or does it evaluate them in order?
>>
>>How would VFP evaluate the following IF statement?
>>
>>c1 = "1"
>>c2 = "X"
>>c3 = "X"
>>
>>IF c1 = "1" or c2 = "2" and c3 = "3"
>>
>>Would it evaluate the previous IF statement to be like the first or second IF statement below?
>>
>>if (c1 = "1" or c2 = "2") and c3 = "3" && evaluates to .f.
>>if c1 = "1" or (c2 = "2" and c3 = "3") && evaluates to .t.
>>
>>Thanks - Brenda
>
>
> It evaluates like your second example. (.T.) But actually it only does the first part. The other two parts are not actually evaluated. You can see this by trying this:
>
>if c1() or c2() and c3()
>endif
>
>function c1
>messagebox('c1')
>
>function c2
>messagebox('c2')
>
>function c3
>messagebox('c3')
>
>Only the "c1" message displays.

As a follow up, if you change the c1 function to return .f., then all 3 functions execute. So there is an implied set of parentheses the same as your second example.
Fred
Microsoft Visual FoxPro MVP

foxcentral.net
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform