If OR - Syntax?

Hints, tips and tricks for newbies

Moderators: Dorian (MJT support), JRL

Post Reply
PaulSR
Pro Scripter
Posts: 65
Joined: Mon Aug 05, 2013 2:58 pm
Location: Edinburgh/Peterborough

If OR - Syntax?

Post by PaulSR » Tue Mar 18, 2014 4:39 pm

Hello again,

Another problem I've looked around for but can't seem to solve - I'm trying to write a very simple if OR command but I keep getting a syntax error. I was looking at the reply from Marcus in this thread but it doesn't work for me.

post33869.html?sid=22da4c4b9936824946baa12192c62e72

Here's a stripped down slice - the problem is with the IF line obviously ;)

Code: Select all

Let>FlagA=Y
Let>FlagB=Y

If>{(%FlagA="Y") OR (%FlagB%="N")}
    MessageModal>Yep
Else
    MessageModal>Nope
EndIf
Any help greatly appreciated !

Thanks,

Paul.

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

Post by Marcus Tettmar » Tue Mar 18, 2014 4:50 pm

You have a missing '%' character. Should be:

If>{(%FlagA%="Y") OR (%FlagB%="N")}

Once the % is added it works correctly.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

PaulSR
Pro Scripter
Posts: 65
Joined: Mon Aug 05, 2013 2:58 pm
Location: Edinburgh/Peterborough

Post by PaulSR » Tue Mar 18, 2014 4:57 pm

Oh dear how embarassing.

Thanks for that !

PaulSR
Pro Scripter
Posts: 65
Joined: Mon Aug 05, 2013 2:58 pm
Location: Edinburgh/Peterborough

Post by PaulSR » Thu Mar 20, 2014 8:39 am

Tip for anybody else as what confused me (apart from the obvious missing %) was the fact that MS will report a syntax error if the variables haven't been set beforehand.

i.e if you take away one of the let> commands in the above code it'll report a syntax error followed by a parsing one which is slightly misleading (to me).

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 20, 2014 9:30 am

This is true for complex expressions (stuff inside {..}) because variables have to be denoted by %..% in complex expressions. So if the variable hasn't been set %var% resolves to just the string %var% but complex expressions also need quotes ".." and they aren't there, so it's a parsing error. If the variable exists and is found then the quotes are added. I suppose we could make it add quotes so that it is looking at literals but then you may not get an error/warning at all and may think it is working.

Outside of complex expressions where quotes are not needed you would not get an error because %var% is still a valid string.

We'll see if we can make the errors clearer :-)
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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

Post by jpuziano » Thu Mar 20, 2014 6:35 pm

Thanks PaulSR for the TIP above and thanks Marcus for explaining what is going on... to see this in action, I just ran the following code:

Code: Select all

//Let>FlagA=Y
Let>FlagB=Y

If>{(%FlagA%="Y") OR (%FlagB%="N")}
    MessageModal>Yep
Else
    MessageModal>Nope
EndIf
First error message wrote:---------------------------
Macro Scheduler
---------------------------
Line: 4 Syntax error
---------------------------
OK
---------------------------
After clicking OK on above error message, then this second error message wrote:---------------------------
Macro Scheduler
---------------------------
Line: 4 Error Parsing Expression
---------------------------
OK
---------------------------
Yes it would be great if one of these error messages could say something clearer, perhaps something like...
---------------------------
Macro Scheduler
---------------------------
Line: 4 Error Parsing Expression, Undefined Variable: FlagA
---------------------------
OK
---------------------------
Thanks!
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 - :-)

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

Post by Marcus Tettmar » Mon Mar 24, 2014 2:13 pm

As I said:
We'll see if we can make the errors clearer
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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