Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

“or” operator 1

Status
Not open for further replies.

dawtes

Programmer
Jun 23, 2005
31
US

Hello, I need to know how the “or” operator works? Does it check all the conditions whether they are true or false even if it finds the true condition or Does it skip the rest of the condition statements when it finds the first true condition.
Thanks.
 
Code:
local numbervar array test;
redim test[1];
test[1] := 2;

local numbervar i := 100;

[b]if (i = 100) or (test[i] > 0) then[/b]
    "Yes"
else
    "No";
That formula returns "Yes" when I run it.

The one below gives an "subscript out of range" error:
Code:
local numbervar array test;
redim test[1];
test[1] := 2;

local numbervar i := 100;

[b]if (test[i] > 0) or (i = 100) then[/b]
    "Yes"
else
    "No";
So the answer to your question is that Crystal Reports uses short-circuit evaluation. It does not check all conditions in an OR statement. As soon as the first condition is true, the whole statement is said to be true and all other conditions are ignored.

JC

_________________________________________________
To get the best response to a question, read faq222-2244.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top