Page 1 of 1

Another if question

Posted: Fri Nov 30, 2012 4:45 pm
by Nibor
Hey guys,
I've a quick question about the "if" again..
this is my code

if vRS is empty or begins with "revdber"
then
answer "please check your username and password." && vRS
exit to top
else
answer "connected."
end if

livecode says
Script compile error:
Error description: Expression: double binary operator

anybody knows what's wrong with my code ?

Re: Another if question

Posted: Fri Nov 30, 2012 5:23 pm
by Klaus
Hi Nibor,

you always need to evaluate the COMPLETE expression!
Parentheses not neccessary, but they won't hurt and will show you how Livecode will see the situation :D

## Your script:
...
if (vRS is empty) or (begins with "revdber")
## So Livecode is asking itself: WHAT the heck begins with "revdber", finds no answer and finally complains! 8)
...
## Correct:
if (vRS is empty) or (vRS begins with "revdber")
...
Livecode will evaluate both expressions separately first: (vRS is empty) and (vRS begins with "revdber")
and then does the comparison of the two resulting Boolean values (true/false) with OR or AND.


Best

Klaus