Inline Comment

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Locked
armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Inline Comment

Post by armsys » Wed Nov 11, 2015 10:56 pm

Referring to the following code:

Code: Select all

Let>RP_WINDOWMODE=2  /* Test 1 */
MDL>RP_WINDOWMODE    /* Test 2 */
MDL>RP_WINDOWMODE
MDL>{"2015.11.11 "}  /* Test 3 */
MDL>{"2015.11.11 "}
Why are the MDL results so different?

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

Re: Inline Comment

Post by Marcus Tettmar » Thu Nov 12, 2015 11:17 am

You have spaces. Read this:
https://www.mjtnet.com/manual/index.htm ... spaces.htm

Code: Select all

Let>IGNORESPACES=1
Let>RP_WINDOWMODE=2  /* Test 1 */
MDL>RP_WINDOWMODE    /* Test 2 */
MDL>RP_WINDOWMODE
MDL>{"2015.11.11 "}  /* Test 3 */
MDL>{"2015.11.11 "}
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

armsys
Automation Wizard
Posts: 1108
Joined: Wed Dec 04, 2002 10:28 am
Location: Hong Kong

Re: Inline Comment

Post by armsys » Thu Nov 12, 2015 12:06 pm

Marcus Tettmar wrote:You have spaces.
Thank you for pointing out the exact cause of different results.
I have done my own extensive tests and confirm your prognosis.

Code: Select all

Let>RP_WINDOWMODE=2  /* Test 1 */
MDL>RP_WINDOWMODE    /* Test 2 */
Referring to the code above, in the absence of IGNORESPACES=1, MS interprets line 2 as displaying a variable named

Code: Select all

"RP_WINDOWMODE    "
(including all spaces before slash), which, of course, was never initiated. Hence, MS display

Code: Select all

"RP_WINDOWMODE    "
itself on the screen.
That's rather an unexpected behavior for an inline comment.
Indeed, IGNORESPACES=1 can apply to the statement with an inline comment. Namely, it eliminates all spaces trailing after the variable name.

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

Re: Inline Comment

Post by Marcus Tettmar » Thu Nov 12, 2015 12:46 pm

Armsys - you've been using Macro Scheduler for what, 10 years or more? So why is this unexpected?

What if you WANT spaces at the end of the line? Let's say we trimmed the line and then you wanted to output a string of spaces? Would you complain that this was unexpected behaviour?

Macro Scheduler has always, by default, made things simple for new users by not forcing you to quote strings or variables. As a result we must leave spaces intact because the user may intend them.

But, *IF*, you do NOT want those spaces then we need to do things differently. First we set IGNORESPACES on so that the spaces are ignored and THEN if you DO want spaces at the end of a string you'll have to QUOTE the string.

You can have it either way. The default way or the second way. It can't be both. We can't guess what the user wants and we also want backward compatibility. If we change the behaviour now many thousands of scripts will fail to work, because believe it or not there are often cases where you WANT spaces at the end of a string.

You've been a user for many years. I'm very surprised that you find this unexpected. There are very valid reasons why it works the way it works. And we've provided options (IGNORESPACES and {"..."}) to make it work more like regular programming languages if that is what you want.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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