Another if question

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Nibor
Posts: 18
Joined: Wed Nov 21, 2012 12:13 pm

Another if question

Post by Nibor » Fri Nov 30, 2012 4:45 pm

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 ?

Klaus
Posts: 14199
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Another if question

Post by Klaus » Fri Nov 30, 2012 5:23 pm

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

Post Reply