If statement problematic if it contains a multiply

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
evangelmike
Pro Scripter
Posts: 56
Joined: Sun May 11, 2008 9:39 pm

If statement problematic if it contains a multiply

Post by evangelmike » Thu Mar 11, 2010 5:57 am

I just made an interesting discovery (after about an hour of hard debugging). Macro Scheduler completely ignores the following statement, and gives no error message indicating that it has done so:

If>SheetMarketCap>400.0*ComptdMarketCap
where ComptdMarketCap is a variable.

Therefore one must write:

If>SheetMarketCap>{400.0*%ComptdMarketCap%}

Has any one else noticed this. Thanks!
May you have a blessed day!

Michael D Fitzpatrick
Reg. US Patent Agent

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Thu Mar 11, 2010 9:02 am

Hi,

This is correct and as documented. Please see the help file topic for "If" where it says:
The expression can be simple (legacy), or complex.



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%.



Several types of operators and functions can be used with complex expressions. For more details see Complex Expressions.



Simple Expressions



Simple expressions can contain only two parts separated by one of the following operators:



= Equals

> Greater than

Not Equal
So you could do:

Let>testVal=400*ComptdMarketCap
If>SheetMarketCap>testVal

or

If>SheetMarketCap>{400&%ComptdMarketCap}
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

evangelmike
Pro Scripter
Posts: 56
Joined: Sun May 11, 2008 9:39 pm

Post by evangelmike » Thu Mar 11, 2010 3:09 pm

Hi Marcus:
Thanks! I think you meant:

"or

If>SheetMarketCap>{400*%ComptdMarketCap} " (*; not &)

Also, perhaps for the next update of the manual, it could be explained under what circumstances a complex expression must be used in an IF statement. May you have a blessed day.
May you have a blessed day!

Michael D Fitzpatrick
Reg. US Patent Agent

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Thu Mar 11, 2010 4:25 pm

evangelmike wrote:Also, perhaps for the next update of the manual, it could be explained under what circumstances a complex expression must be used in an IF statement. May you have a blessed day.
Hi evangelmike,

I have wondered that myself... but on re-reading the existing Help File entry for IF, you'll find these statements:
out-takes from the existing Help File entry for the If> statement wrote: If>expression[,true_label_name[,false_label_name]]
statements
[ [Else
else statements]
Endif ]

The expression can be simple (legacy), or complex.

Simple expressions can contain only two parts separated by one of the following operators:

= Equals
> Greater than
Not Equal

Values in the expression can be numeric or string values, or variables containing such values.
From the above, you can infer that the following would not qualify as a simple expression:

SheetMarketCap>400.0*ComptdMarketCap

SheetMarketCap is OK as it is a single value to the left of the SheetMarketCap>{400*%ComptdMarketCap%}
//do something
ELSE
//do something else
ENDIF[/quote]
Thanks and take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

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