Complex Expressions

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
TheEek
Junior Coder
Posts: 31
Joined: Mon Jun 22, 2009 2:53 pm

Complex Expressions

Post by TheEek » Mon Jun 29, 2009 12:50 pm

Not that complex, but enough for me to get confused by...

Code: Select all

Let>serverOneAccess=True
serverOneAccess can equal "Y", "True" or "anyother value", it's taken from user input. I'm trying to catch that "anyother value".

Code: Select all

If>{(%serverOneAccess%<>"Y")OR(%serverOneAccess%<>"True")}
      Do Stuff...
      exit
endif
do other stuff...
exit
For some reason "Do stuff" is always executed, and not "do other sutff" no matter what serverOneAccess equals. In other words if serverOneAccess equals "Y" or "True" go and "do other stuff". The reason I don't use:

Code: Select all

If>{(%serverOneAccess%="Y")OR(%serverOneAccess%="True")}
     Goto>do other stuff
else>
      Do Stuff...
      exit
endif
do other stuff...
exit
..is because in the end, I'm trying to add 8 variables, each can be "Y", "True", or something else. I was trying to get them all on one line rather than 8 nested if statements.

Code: Select all

If>{(%serverOneAccess%<>"Y")OR(%serverOneAccess%<>"True")OR(%serverTwoAccess%<>"Y")OR(%serverTwoAccess%<>"True")} ...etc
      Do Stuff...
      exit
endif
do other stuff...
exit
Can you help me please?

*edit1 spelling and improved explanation

User avatar
JRL
Automation Wizard
Posts: 3532
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Mon Jun 29, 2009 1:00 pm

Your complex expression syntax is good. The logic is the problem. The value of "serverOneAccess" will always not equal "Y" OR not equal "True". Think about it.

Perhaps you want:

If>{(%serverOneAccess%="Y")OR(%serverOneAccess%="True")}
Do other Stuff...
exit
endif
do stuff...
exit

TheEek
Junior Coder
Posts: 31
Joined: Mon Jun 22, 2009 2:53 pm

Post by TheEek » Mon Jun 29, 2009 1:32 pm

I'm trying to catch the "anyother value". For example, there is a cluster of 7 servers. A user can have access to one, some or all of them. But if the request is made for none of them, I want the script to take the necessary actions:

Code: Select all

if>{(%serverOneAccess%<>"True")OR(%serverAccess%<>"Y")OR(%serverTwoAccess%<>"True")OR(%serverTwoAccess%<>"Y")OR(%serverThreeAccess%<>"True")OR(%serverThreeAccess%<>"Y")OR(%serverFourAccess%<>"True")OR(%serverFourAccess%<>"Y")OR(%serverFiveAccess%<>"True")OR(%serverFiveAccess%<>"Y")OR(%serverSixAccess%<>"True")OR(%serverSixAccess%<>"Y")OR(%serverSevenAccess%<>"True")OR(%serverSevenAccess%<>"Y")}    
	Messagemodal>You didn't request access to any of the servers
	exit
endif

...continue with script...
(The if statement is all on one line).
In other words, the user has to have at least one of the server set to "Y" or "True"

TheEek
Junior Coder
Posts: 31
Joined: Mon Jun 22, 2009 2:53 pm

Post by TheEek » Mon Jun 29, 2009 1:37 pm

Many thanks for your help - it finally sunk in.

Code: Select all

if>{(%serverOneAccess%="True")OR(%serverAccess%="Y")OR(%serverTwoAccess%="True")OR(%serverTwoAccess%="Y")OR(%serverThreeAccess%="True")OR(%serverThreeAccess%="Y")OR(%serverFourAccess%="True")OR(%serverFourAccess%="Y")OR(%serverFiveAccess%="True")OR(%serverFiveAccess%="Y")OR(%serverSixAccess%="True")OR(%serverSixAccess%="Y")OR(%serverSevenAccess%="True")OR(%serverSevenAccess%="Y")}    
	Goto continueWithScript
endif

messagemodal>complain and moan
exit

label>continueWithScript...

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts