Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
EVL and NVL
Message
 
 
To
20/05/2004 13:33:29
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00905138
Message ID:
00905760
Views:
34
Fabio,

Your statements are mixing two distinctly different things.

1) the return value of: operand1 logicaloperator operand2 bolded below
2) the logical expression evaluator being able to stop evaluating operands once the result is deterministic italics below

>.NULL. AND m.X < === must return .null. if m.X is .T., then m.X must to be evaluated

>No this is incorrect.

It is correct both in the returned value and whether or not m.X is evaluated.

>It is not the value of m.X that it determines if must or not must eval m.X,
>but the fact that I must know if it is .F. ( for .AND. ) or .T. ( for .OR. ).

It is the current value of the intermediate result and the logical operator that determines whether or not the rest of the expression needs to be evaluated.
   X   |   Y    |  X and Y   |  X OR Y
-------+--------+------------+----------
.T.    | .T.    | .T.    X Y | .T.     X 
.T.    | .F.    | .F.    X Y | .T.     X 
.T.    | .NULL. | .NULL. X Y | .T.     X 
.F.    | .T.    | .F.    X   | .T.     X Y 
.F.    | .F.    | .F.    X   | .F.     X Y 
.F.    | .NULL. | .F.    X   | .NULL.  X Y 
.NULL. | .T.    | .NULL. X Y | .T.     X Y 
.NULL. | .F.    | .F.    X Y | .NULL.  X Y 
.NULL. | .NULL. | .NULL. X Y | .NULL.  X Y
In the above table lists the result of the expression and where X Y appears below the line it means that operand was evaluated. Note that whenever null is the left operand both operands must be evaluated.

Here is the code that generated the result:
select 0

local laBool[3]
laBool[1] = .t.
laBool[2] = .f.
laBool[3] = .null.

? "   X   |   Y    |  X and Y   |  X OR Y"
? "-------+--------+------------+----------"

for i = 1 to 3
   x = laBool[i]
   for j = 1 to 3
      y = laBool[j]
      ? x, " | "
      ?? y, " | "
      lcRead = ""
      ?? IsEval( "X" ) and IsEval( "Y" ), lcRead, " | "
      lcRead = ""
      ?? IsEval( "X" ) or IsEval( "Y" ), lcRead
   endfor
endfor

function IsEval( lcOperand )
lcRead = lcRead + lcOperand + " "
return eval( lcOperand )
df (was a 10 time MVP)

df FoxPro website
FoxPro Wiki site online, editable knowledgebase
Previous
Reply
Map
View

Click here to load this message in the networking platform