|
Sogdog Newbie
Joined: 11 Dec 2007 Posts: 8
|
Posted: Mon Feb 02, 2009 8:20 am
help with #IF |
Hello all,
I know this is basic basic stuff, so sorry for that.
I did have a look for the answer myself, but the Zmud help files are a little thin on the usage of #if commands.
#if (@var1=0 AND @var2=0) {action1}
#if (@var1=1 OR @var2=1) {action2}
#if (@var1=1 AND @var2=1) {action3}
So as you can see I have two variables and three possible outcomes. As you can guess, what I have doesn't work. I'm assuming from my very limited knowledge there needs to be some brackets in there, but I don't have a clue where they go.
A bit of help to get me started would be much appreciated.
ps (It is just my assumption that the OR operator can be used, I haven't found any documentation on that either) |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4690 Location: Pensacola, FL, USA
|
Posted: Mon Feb 02, 2009 10:09 am |
The syntax you use in those examples looks spot on.
Perhaps you can show us the part you having trouble with? |
|
_________________ Discord: Shalimarwildcat |
|
|
|
Sogdog Newbie
Joined: 11 Dec 2007 Posts: 8
|
Posted: Mon Feb 02, 2009 10:23 am |
Thank you, your reassurances made me go back and check everything....and take out the spelling mistake.
Everything works fine now. Cheers muchly!! |
|
|
|
Sogdog Newbie
Joined: 11 Dec 2007 Posts: 8
|
Posted: Mon Feb 02, 2009 12:34 pm |
But what I didn't see coming was when the third #IF statement is true, then the second #IF statement must be true as well, and both actions 2 and 3 will fire.
Back to that board with drawings on it...heh |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Mon Feb 02, 2009 3:22 pm |
Yes... logical OR isn't like the word "or" you use in conversation. "You can have cake or pie" implies that only one is true, but logical or means one or the other or both. There's a separate operation for what you're looking for, called XOR, but I'm not sure that that's supported in zScript the same way that AND and OR are. It's better just to use a logic tree for this:
Code: |
#if (@var1=0) {
#if (@var2=0) {action1} {action2}
} {
#if (@var2=0) {acton2} {action3}
} |
|
|
|
|
|
|