%Variable%(???)

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

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

Post by JRL » Sun Apr 14, 2013 8:18 pm

PepsiHog wrote:On a personal note. I don't use Assigned. I just check the string for what I am looking for. Or check if it is equal to nothing. But, six to one, half a dozen to another.
Me too. I haven't used Assign> since Marcus pointed out several years ago that its easier (he didn't exactly say that it is my conclusion) to just test to see if the variable is equal to the text of the variable. In other words

If>Variable={"Variable"}

Then nothing is assigned to the variable because it is still equal to its own text value.

Not that assigned isn't still more precise. For example if you assign a variable its text as a value, Assigned> will detect that the variable has been assigned a value.

Let>Variable={"Variable"}
Assigned>Variable,res

Will detect that "Variable" has been assigned a value

Let>Variable={"Variable"}
If>Variable={"Variable"}

will not differentiate between variable "Variable" having been assigned its own text as a value and its not having been assigned any value.
armsys wrote: How to detect a parameterized variable has been assigned?
Not sure about the meaning of "parameterized variable" but I think I understand what you want. Use the *test to see if variable and variable text are equal* method.

Code: Select all

Let>List=One%crlf%two%crlf%three%crlf%four
Separate>List,crlf,var

Let>kk=0
Label>Loop
  Add>kk,1
  //Test "parameterized variable"
  If>var_%kk%={"var_%kk%"}
    mdl>done  -  no value found for var_%kk%
    Exit
  EndIf
  Let>value=var_%kk%
  message>value
  Wait>1
Goto>Loop
[/quote]

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

Post by armsys » Sun Apr 14, 2013 8:43 pm

Hi JRL,
Your If>Variable={"Variable"} is the best solution I've looking for years. It's simple and elegant. Thanks a lot.
BTW, instead of "parameterized variable," how would you call these variables with %% things?
JRL, thanks for taking time to sharing with us your magnificent Macro Scheduler coding technique.

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

Post by JRL » Sun Apr 14, 2013 8:51 pm

Your If>Variable={"Variable"} is the best solution I've looking for years.
I like it. But don't thank me... Marcus posted this a few years ago. I looked for his post to link to it but didn't find it.

I would think "parameterized variable" might refer to a variable passed to a script as a parameter. I could be wrong but I think variables in the form "var_%counter%" are generally refered to as "arrayed variables".

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

Post by armsys » Sun Apr 14, 2013 9:37 pm

JRL,
Thanks for your quick reply.

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