Passing 0000 to a SRT with explicit variable {} will be passed as "0"

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
Grovkillen
Automation Wizard
Posts: 766
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Passing 0000 to a SRT with explicit variable {} will be passed as "0"

Post by Grovkillen » Tue Sep 14, 2021 4:08 pm

Not expected behavior...

Code: Select all

Let>ZERO_VALUE=0
Let>k=0
Repeat>k
  Let>k=k+1
  GoSub>DISPLAY_VALUE,ZERO_VALUE
  ConCat>ZERO_VALUE,0
Until>k=3
Let>k=0
Repeat>k
  Let>k=k+1
  GoSub>DISPLAY_VALUE,{%ZERO_VALUE%}
  //MDL will show "0" even though "ZERO_VALUE" = 00..N
  ConCat>ZERO_VALUE,0
Until>k=3

SRT>DISPLAY_VALUE
  MDL>DISPLAY_VALUE_Var_1
END>DISPLAY_VALUE
Let>ME=%Script%

Running: 15.0.19b
version history

User avatar
Grovkillen
Automation Wizard
Posts: 766
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Re: Passing 0000 to a SRT with explicit variable {} will be passed as "0"

Post by Grovkillen » Tue Sep 14, 2021 4:46 pm

Here's another thing I wasn't expecting:

Code: Select all

Let>ONE_ZERO=0
Let>MULTI_ZERO=0000

If>ONE_ZERO=MULTI_ZERO
 MDL>%ONE_ZERO% = %MULTI_ZERO%
Endif>
Multiple zeroes should (in my opinion) be treated as strings and not numbers.
Let>ME=%Script%

Running: 15.0.19b
version history

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

Re: Passing 0000 to a SRT with explicit variable {} will be passed as "0"

Post by JRL » Wed Sep 15, 2021 8:39 pm

Multiple zeroes should (in my opinion) be treated as strings and not numbers.
Its a matter of syntax.

Code: Select all

Let>ONE_ZERO=0
Let>MULTI_ZERO=0000
//Let>MULTI_ZERO=0
If>{"%ONE_ZERO%"="%MULTI_ZERO%"}
 MDL>%ONE_ZERO% = %MULTI_ZERO%
Endif>

User avatar
Grovkillen
Automation Wizard
Posts: 766
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Re: Passing 0000 to a SRT with explicit variable {} will be passed as "0"

Post by Grovkillen » Wed Sep 15, 2021 8:45 pm

Also when passing them to a sub routine?
Let>ME=%Script%

Running: 15.0.19b
version history

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

Re: Passing 0000 to a SRT with explicit variable {} will be passed as "0"

Post by JRL » Wed Sep 15, 2021 9:25 pm

Add the quotes
GoSub>DISPLAY_VALUE,{"%ZERO_VALUE%"}

Code: Select all

Let>ZERO_VALUE=0
Let>k=0
Repeat>k
  Let>k=k+1
  GoSub>DISPLAY_VALUE,ZERO_VALUE
  ConCat>ZERO_VALUE,0
Until>k=3
Let>k=0
Repeat>k
  Let>k=k+1
  GoSub>DISPLAY_VALUE,{"%ZERO_VALUE%"}
  //MDL will show "0" even though "ZERO_VALUE" = 00..N
  ConCat>ZERO_VALUE,0
Until>k=3
SRT>DISPLAY_VALUE
  MDL>DISPLAY_VALUE_Var_1
END>DISPLAY_VALUE

User avatar
Grovkillen
Automation Wizard
Posts: 766
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Re: Passing 0000 to a SRT with explicit variable {} will be passed as "0"

Post by Grovkillen » Thu Sep 16, 2021 7:53 am

Ah, yeah I knew that but then I remembered why I cannot rely on using quotes:

Code: Select all

Let>ZERO_VALUE=0"
Let>k=0
Repeat>k
  Let>k=k+1
  GoSub>DISPLAY_VALUE,ZERO_VALUE
  ConCat>ZERO_VALUE,0"
Until>k=3
Let>k=0
Repeat>k
  Let>k=k+1
  GoSub>DISPLAY_VALUE,{"%ZERO_VALUE%"}
  //above will error due to the " in the string
  ConCat>ZERO_VALUE,0"
Until>k=3
SRT>DISPLAY_VALUE
  MDL>DISPLAY_VALUE_Var_1
END>DISPLAY_VALUE
This is how my code looks like, all over the place... it's a pain:

Code: Select all

Let>ZERO_VALUE=0"
Let>k=0
Repeat>k
  Let>k=k+1
  GoSub>DISPLAY_VALUE,ZERO_VALUE
  ConCat>ZERO_VALUE,0"
Until>k=3
Let>k=0
Repeat>k
  Let>k=k+1
  StringReplace>ZERO_VALUE,",----''----,ZERO_VALUE
  GoSub>DISPLAY_VALUE,{%ZERO_VALUE%}
  //No quotes when calling the subroutine
  ConCat>ZERO_VALUE,0"
Until>k=3
SRT>DISPLAY_VALUE
  StringReplace>DISPLAY_VALUE_Var_1,----''----,",DISPLAY_VALUE_Var_1
  MDL>DISPLAY_VALUE_Var_1
END>DISPLAY_VALUE
Let>ME=%Script%

Running: 15.0.19b
version history

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

Re: Passing 0000 to a SRT with explicit variable {} will be passed as "0"

Post by Marcus Tettmar » Thu Sep 16, 2021 10:44 am

0000 is 0
If you want a string it would be {"0000"}
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
Grovkillen
Automation Wizard
Posts: 766
Joined: Fri Aug 10, 2012 2:38 pm
Location: Hudiksvall, Sweden
Contact:

Re: Passing 0000 to a SRT with explicit variable {} will be passed as "0"

Post by Grovkillen » Thu Sep 16, 2021 11:22 am

Got ya!

How about the thing if a string contains a quote and I want to pass it to a sub routine?
Let>ME=%Script%

Running: 15.0.19b
version history

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