problem to use if with And and OR...?

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
caomeisanhao
Junior Coder
Posts: 28
Joined: Wed Jun 08, 2005 2:48 pm

problem to use if with And and OR...?

Post by caomeisanhao » Tue Jul 19, 2005 3:05 pm

Hi,guys

I have a problem.how to use if with And and OR including system Valiable...?

For Example: I am using PC with computername snake

If>{(%COMPUTER_NAME%="sn1") or (%COMPUTER_NAME%="sn2")}
MessageModal>%COMPUTER_NAME%
Do stuff...
Endif

It doesnot work. Why? something wrong with spaces?

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Jul 19, 2005 3:34 pm

I see no problem with the syntax. This works for me:

Code: Select all

Let>COMPUTER_NAME=sn1
//Toggle next line with previous line for testing
//Let>COMPUTER_NAME=sn2  (\
If>{(%COMPUTER_NAME%="sn1") or (%COMPUTER_NAME%="sn2")}
MessageModal>%COMPUTER_NAME%
//Do stuff...
Endif 
You don't show the full script where the variables are assigned values.
Remember that variables are Case Sensitive.
Also remember to Remove Trailing Spaces

Using 7.3.11.4
Last edited by Bob Hansen on Tue Jul 19, 2005 4:28 pm, edited 1 time in total.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Jul 19, 2005 3:37 pm

Which version of Macro Scheduler do you have? Check under Help/About.
MJT Net Support
[email protected]

caomeisanhao
Junior Coder
Posts: 28
Joined: Wed Jun 08, 2005 2:48 pm

my MS version is 7.3.11.4

Post by caomeisanhao » Wed Jul 20, 2005 11:23 am

my MS version is 7.3.11.4

caomeisanhao
Junior Coder
Posts: 28
Joined: Wed Jun 08, 2005 2:48 pm

help me!

Post by caomeisanhao » Wed Jul 20, 2005 11:45 am

ok,I have made a small test.
I want to check the computername that I use currently.if the PCs with the name that i expect, it will show a messagebox with the name of PC.
COMPUTER_NAME is system Variable from MacroScheduler.

If>%COMPUTER_NAME%="PC1234"
MessageModal>%COMPUTER_NAME%
Endif

And I go to PC1234, run the script above,nothing happens.It does not work.
when I run just "MessageModal>%COMPUTER_NAME%" ,without If/Endif.It works fine.But I donot want all PCs to show its name.Help me please!

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

Post by JRL » Wed Jul 20, 2005 1:20 pm

You don't need or want the quotes around the computer's name. Try:

If>%COMPUTER_NAME%=PC1234
MessageModal>%COMPUTER_NAME%
Endif

On the other hand, if you were using complex if statements as in your original posting, the quotes are necessary.

Quoting form the Macro Scheduler help for complex expressions:
The expression must be contained within curly braces "{" and "}". String literals must be delimited with double quotes ("), e.g.: "string".
Variables must be delimited with % symbols, e.g.: %VarA%.
Hope this helps,
Dick

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Wed Jul 20, 2005 3:24 pm

Both the original and simplified version work for me too.

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