Unruly Variable Names

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

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

Unruly Variable Names

Post by armsys » Fri Oct 30, 2015 10:46 am

I'm stunned to discover that Macro Scheduler in fact imposes no rule on variable naming.
The following code shows "xy*! 2" is legally allowed as a variable name!
But it's useless as it isn't recognized subsequently by other commands.

Code: Select all

Let>xy*!  2=123
Let>y=xy*!  2
MDL>xy*!  2=123

User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: Unruly Variable Names

Post by PepsiHog » Sat Oct 31, 2015 9:27 pm

Yeah, I know. It's AWESOME, isn't it?

Marcus,

Please, please, please, please, do not add rules to variable naming. It allows so MANY possibilities.

Thanks,
PepsiHog

[Edit] - Ok, he's right. I can't get any results either. But that's why we debug. Start adding rules and next thing we know, we can't do things like:

let>ase=1
let>Creative_%ase%=Some crazy
-or-
let>%MyVar%=Twisted

and many more! (Yes, these examples work, given they are defined.)

This is one of my most favorite things about MS. You can be SOOOOO creative!
Last edited by PepsiHog on Sat Oct 31, 2015 10:08 pm, edited 1 time in total.
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

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

Re: Unruly Variable Names

Post by armsys » Sat Oct 31, 2015 9:54 pm

PepsiHog wrote:Yeah, I know. It's AWESOME, isn't it?
Hi PepsiHog,
It's fantastic to see you back here.
Could you entertain us with your samples of AWESOME unruly variable names?

User avatar
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: Unruly Variable Names

Post by PepsiHog » Sat Oct 31, 2015 10:09 pm

Just did. Thanks. Nice to see you.

You must be the type that follows rules. I have known about this stuff since v10. Maybe you should do more test drives. :)

PepsiHog

Below is wrong, I am running v14. Just haven't changed it yet. And Windows 7.....newer laptop. You get the idea.
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

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

Re: Unruly Variable Names

Post by JRL » Sun Nov 01, 2015 1:15 am

Let>xy*! 2=123
Take out the spaces and the variable will work.

Code: Select all

Let>xy*!2=123
mdl>xy*!2
Spaces can cause variables to fail so don't use them. This fails and has no quirky characters

Code: Select all

Let>mm mm=2
mdl>%mm mm%
I don't know any other character that is on the keyboard that shouldn't be used... wait... no... don't use tabs either as part of a variable name. And though they will work it could be detrimental to use numbers as variables. For example.

Code: Select all

Let>1234=2
mdl>1234

Let>kk=1
Add>kk,1234
MDL>kk
I like using descriptive variables and I also like to start variable names with a lower case "v".

Code: Select all

ReadFile>%temp_dir%myTextFile.txt,vData

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

Re: Unruly Variable Names

Post by armsys » Sun Nov 01, 2015 5:14 am

Hi JRL & PepsiHog,
Thank you for sharing your insight on unruly variable naming.
I didn't know the naughty space is a showstopper.
JRL's variable is certainly a delightful entrapment:

Code: Select all

Let>1234=2
mdl>1234
Let>kk=1
Add>kk,1234
MDL>kk
Everyone will be stunned to find out that KK results in 3, not 1235.
Thank you again.

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

Re: Unruly Variable Names

Post by Marcus Tettmar » Tue Nov 03, 2015 11:26 am

This has been the case since, wait, 1997. But if you want a more "traditional" approach use VAREXPLICIT. It's in the manual, under, of all places, "Using Variables". So if you do this:

Code: Select all

Let>VAREXPLICIT=1
Let>1234=2
mdl>1234
Let>kk=1
Add>kk,1234
MDL>kk
You will be stunned to know that kk now equals 1235
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
PepsiHog
Automation Wizard
Posts: 517
Joined: Wed Apr 08, 2009 4:19 pm
Location: Florida

Re: Unruly Variable Names

Post by PepsiHog » Thu Nov 26, 2015 12:38 pm

Ha! LOL! In your face! You go Marcus! :D
Windows 7

PepsiHog. Yep! I drink LOTS of Pepsi (still..in 2024) AND enjoy programming. (That's my little piece of heaven!)

The immensity of the scope of possibilities within Macro Scheduler pushes the user beyond just macros!

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