Complex expressions

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
Robbyn
Junior Coder
Posts: 43
Joined: Tue Feb 15, 2005 9:55 pm

Complex expressions

Post by Robbyn » Sun Jan 08, 2006 2:16 pm

What is wrong with:

let>line1={Upper(%line%)}

MS is reporting a syntax error.

Using the complex expression how do I set out

If>(a=0 or b=0 or C=0) and d>0
Robin

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

Post by JRL » Sun Jan 08, 2006 4:56 pm

What is wrong with:
let>line1={Upper(%line%)}
MS is reporting a syntax error.

Nothing wrong with the expression. You will get the syntax error if "line" has no value.
Using the complex expression how do I set out
If>(a=0 or b=0 or C=0) and d>0
Try this in the editor using the debugger, set different values for a, b, c, d .
Let>a=1
Let>b=1
Let>c=0
Let>d=0

If>{(%a%=0) or (%b%=0) or (%c%=0) and (%d%>0)}
MDL>Conditions were met.
Else
MDL>Conditions were not met
EndIF


Hope this helps,
Dick

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 » Sun Jan 08, 2006 5:05 pm

let>line1={Upper(%line%)}
will give a syntax error if %line% has not been declared yet.

The following works OK:

Code: Select all

Let>line=abcde
let>line1={Upper(%line%)}
======================================

From the Help section on "IF",
Variables must be delimited with % symbols
and from the paragraph dealing with complex expressions you wil find:
//complex expression:
IF>{(%a% = 5) AND (%VarA% = "allen")}
//do something
ELSE
//do something else
ENDIF
Again, as noted above, this will only work after you have declared the variables, so, for your example, you must have:

Code: Select all

Let>a=0
Let>b=0
Let>c=0
Lett>d=5
IF>{((%a% = 0) OR (%b%=0) OR (%c%=0)) AND (%d%>0)}
   //do something
ELSE
   //do something else
ENDIF
===========================
Note after posting:
I see that JRL was a bit quicker than me with a solution. Remarkable how similar they both are :D
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

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

Post by Me_again » Sun Jan 08, 2006 6:04 pm

Bob Hansen wrote: I see that JRL was a bit quicker than me with a solution. Remarkable how similar they both are :D


Interesting to note the difference between the solutions too

Bob:

IF>{((%a% = 0) OR (%b%=0) OR (%c%=0)) AND (%d%>0)}

JRL:

If>{(%a%=0) or (%b%=0) or (%c%=0) and (%d%>0)}

User avatar
Captive
Macro Veteran
Posts: 213
Joined: Sun Oct 20, 2002 8:37 pm
Location: Colorado, USA

Post by Captive » Sun Jan 08, 2006 8:18 pm

Bob's is correct.

Although it works in this case, JRL's logic may mean a slightly different thing, in that it "could" mean...

Condition 1: A=0, or B=0
Condition 2: C=0, and D>0

... but that to be safe, the extra ( and ) ensure the conditions are...
Condition 1: A=0, or B=0, or C=0
Condition 2: D>0

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