Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
AND and OR evaluations in conditional statements
Message
De
11/04/1999 19:13:54
 
 
À
10/04/1999 00:23:37
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00206066
Message ID:
00207331
Vues:
17
Hi John..
Try this,
? (.t. or .t.) and .F.
? .t. or .t. and .F.

The second expression *does not* evaluate left to right, it uses precedence.
(It took me a while to find this example, even though it's so simple)

>My understanding is that the MDAS rules apply to expressions but that all ANDS and ORs (logical operators) are evaluated as encountered, left to right, before all else. So, you have this situation:
>
>STORE .F. to x,y
>STORE .T. to z
>
>x AND y AND z = False
>x AND y OR Z = True
>
>Why True? Because the compiler reads the AND and groups x and y and evaluates....then encounters the OR and sets z off in it's own part of the equation. x and y are False but z is therefore, true it is.
>
>
>>>But * IS evaluated before + is every case;
>>>
>>>?5+2*7 && 19
>>>?2*7+5 && 19
>>>?7*2+5 && 19
>>>
>>>The multiplication is always done before the addition.
>>My Dear Aunt Sally (Multiply Divide Add Subtract) Elementry school math...
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform