Retrieve variable name passed as a command line parameter

General Macro Scheduler discussion

Moderators: Dorian (MJT support), JRL

Post Reply
Alpha_AI
Pro Scripter
Posts: 61
Joined: Wed Sep 19, 2007 9:30 am

Retrieve variable name passed as a command line parameter

Post by Alpha_AI » Tue Apr 26, 2011 2:46 am

Hello,

I have

Macro.exe /Force=2 /Mass=3

and I need to find out the name that is passed as a variable.
eg. Force and Mass

In my macro I can retrieve the values by using

Send>%Force%
or
Send>%Mass%

but now I want the

Send>%VariableName% = %Force%
instead.

How do I find out the variable name?

Ben

Alpha_AI
Pro Scripter
Posts: 61
Joined: Wed Sep 19, 2007 9:30 am

Post by Alpha_AI » Tue Apr 26, 2011 2:57 am

I could possibly do a

Macro.exe /VariableCount=2 /VariableNames=Force;Mass /Force=3 /Mass=2

use the seperate function to separate the ; delimiter

Maybe that is the only way.

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

Post by JRL » Tue Apr 26, 2011 12:52 pm

The parameters show up in the "Command_Line" system variable so its possible to separate them out without having to declare them as an additional parameter.

Try this:

Code: Select all

//Remove spaces from the command line to be sure there are
//no extra spaces in the parameters section
StringReplace>command_line, ,,param_line

//Isolate the parameters.  parameter_count-1
//will be the number of parameters
Separate>param_line,/,parameter

//Use a loop to separate each parameter name
//from each parameter value
Let>p_count=1
Repeat>p_count
  Add>p_count,1
  Let>value=Parameter_%p_count%
  Separate>value,=,segment
  //Segment_1 is the parameter name
  //Segment_2 is the parameter value
  MDL>%segment_1%=%segment_2%
Until>p_count=parameter_count

kiohaa
Newbie
Posts: 1
Joined: Fri Mar 06, 2015 5:42 am

Re: Retrieve variable name passed as a command line paramete

Post by kiohaa » Fri Mar 06, 2015 6:00 am

How do I find out the variable name?
watson

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

Re: Retrieve variable name passed as a command line paramete

Post by Marcus Tettmar » Mon Mar 09, 2015 9:57 am

kiohaa wrote:How do I find out the variable name?
JRL wrote://Segment_1 is the parameter name
//Segment_2 is the parameter value
MDL>%segment_1%=%segment_2%
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

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