Logic to resolve variables.

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
EricGB
Newbie
Posts: 5
Joined: Mon Aug 30, 2010 2:10 pm
Location: Belgium

Logic to resolve variables.

Post by EricGB » Tue Aug 31, 2010 2:04 pm

Hi,

I am not very familiar yet with the method(s) used in Macro Scheduler to resolve variables.
I have already seen very interesting topics about usage of %-signs, one of them is that you better not use them unless they are really necessary.

But before I was aware of that, I did the experiments below.
Some are not useful at all, but I used them to show the cases I wanted:

Code: Select all

Let>VAREXPLICIT=0
let>a=b
//a == "b"  immediate value for  b  not found, so  "b"  is result
let>b=c
//b == "c"
let>cb=CitBand
//cb == "CitBand"
let>x=a
//x == "b"  immediate value for  a  found, so it is apparantly used
let>x=%a%
//x == "c"  immediate value for  %a%  not found, so translate 
//          embedded variables:
//          %a% --> "B"
//          then immediate value for  B  found, so  C  is result.
let>x=%a%%b%
//x == "bc" immediate value for  %a%%b%  not found, so translate
//          embedded variables:
//          %a% --> "B",  %b% --> "C"
//          then immediate value for  BC  not found, so  BC  is result.
let>x=%b%%a%
//x == "CitBand"! immediate value for  %b%%a%  not found, so 
//          translate embedded variables:
//          %a% --> "B",  %b% --> "C"
//          then immediate value for  CB  found, so  "CitBand"  is result.
let>x= %b%%a%
//x == " cb" : immediate value for  " %b%%a%"  not found, so translate
//          embedded variables:
//          %a% --> "B",  %b% --> "C"
//          then immediate value for  " cb"  not found, so  " cb"  is result.

Code: Select all

Let>VAREXPLICIT=0
let>e%dos%=ThisIsEdos
let>onetwo=12
let>dos=two
let>x=e%dos%
//x == "ThisIsEdos"  immediate value for  e%dos%  found, 
//          so result is  "ThisIsEdos"
//          Note that "%dos%" is not translated here, 
//          else result would have been "etwo".
let>x=ne%dos%
//x == "netwo"      immediate value for  ne%dos%  not found, so 
//                  translate embedded variable(s)
//                  %dos% --> "two"
//                  then immediate value for  "netwo"  not found, 
//                  so it becomes the result.
let>x=one%dos%
//x == "12"         immediate value for  one%dos%  not found, so 
//                  translate embedded variables
//                  %dos% --> "two"
//                  then immediate value for  "onetwo"  found, so result is  "12"

Are there mistakes in the comments I added after each statement?
Any other comments?

Regards,
Eric.

Dick99999
Pro Scripter
Posts: 84
Joined: Thu Nov 27, 2008 10:25 am
Location: Netherlands

Post by Dick99999 » Thu Sep 02, 2010 10:03 am

I did not go through all resolutions, you could easily write the executable statements and check the result by using MDL>. It does trigger though a thought about string and substitution. MS now supports at least 2 modes:

- Automatic, substitution takes place whenever a variable has an assigned value. When it has not it is automatically considered to be a string.
- Explicit where all variables have to be embedded in percent signs to be substituted.

What I miss is a possibly third variation: explicit string. Variables are substituted and never considered to be a string. A string is quoted like in many programming languages.
My experience is that the auto mode gives more problems than advantages and the explicit mode is cumbersome to type and to read. So any support for the explicit string mode?

And while we are at this issue: an explicit reference to a global variable (perhaps $var) within localvars would be welcome too.

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 Sep 02, 2010 10:12 am

Explicit strings:

Let>mystring={"hello world"}

Or

Send>{"this is a string"}

MessageModal>{"definitely a string"}
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Dick99999
Pro Scripter
Posts: 84
Joined: Thu Nov 27, 2008 10:25 am
Location: Netherlands

Post by Dick99999 » Thu Sep 02, 2010 10:29 am

mtettmar wrote:Explicit strings:

Let>mystring={"hello world"}

Or

Send>{"this is a string"}

MessageModal>{"definitely a string"}
Indeed, and I use that, however
- I thought that {} is used for complex expressions, any penalty or side effect of using it for strings?
- That only resolves the 'this is a string' resolution, not the substitution issue i.e. mystring=my should not result in {"my"} even is it is not assigned, I think...

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