Using flags (arguments) with a macro exe

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Tobias
Junior Coder
Posts: 22
Joined: Mon Jul 19, 2004 1:44 pm
Location: The Netherlands

Using flags (arguments) with a macro exe

Post by Tobias » Fri Feb 09, 2007 11:12 am

Hi,

I've got a situation I cannot figure out myself. Hopefully someone else knows how to solve this.

I am running a program from which I launch macros with flags (argument). The flag is used in the macro.
So far no problem.

However the flag is provided by the program launching the macro and the program uses a variable as flag (called %ON%). %ON% refers to something like the current datafile.

How do I get the variable value provided by the program? I have tried to add /parameter=%ON%, but that results in %ON% as value in te macro. I've also tried various variations, but none seem to work.

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

Post by Marcus Tettmar » Fri Feb 09, 2007 11:27 am

Sorry, I'm confused :oops:

Can you try to explain what you want to accomplish?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Tobias
Junior Coder
Posts: 22
Joined: Mon Jul 19, 2004 1:44 pm
Location: The Netherlands

Post by Tobias » Fri Feb 09, 2007 3:46 pm

I was afraid of it. It is a little bit complicated.

I have this program (let's call it WOW). WOW can send command-line commmands. These commands are macros with an argument. something like: c:\macro.exe argument1

I know I can can use:
c:\macro.exe /var1=argument1
and then use var1 in the macro and that works fine.

WOW can pass one data file names (WOW is a program for manipulating data) on as an argument. So like:
c:\command.exe data_file_1
And that works fine too.

To make is more generic I can use a variable in WOW for the argument. This is %ON%. So the generic command would be:
c:\command.exe %ON% (where %ON% would refer to data_file_1 or data_file_2, etc)

I would like to use this %ON% variable and have the macro use the value WOW assigns to %ON%. Like this:
c:\macro.exe %ON%
This does not work so I tried:
c:\macro.exe /var1=%ON%
However when I use this the macro use %ON% as the value for val1 not the value %ON% gets from WOW (e.g. data_file_1)


So my question is, is there a way to make this work?

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

Post by Marcus Tettmar » Fri Feb 09, 2007 3:56 pm

I think this is a WOW question, not a Macro Scheduler question.

But please clarify - what is calling the Macro Scheduler macro exe?

Clearly it is the responsibility of whatever is CALLING the exe to pass the values. If I have understood you correctly then in this instance the %ON% is outside the context of the macro.

However, if Macro Scheduler itself, or another Macro Scheduler macro/exe is calling the macro then %ON% would reference a local variable called ON. e.g.:

Let>ON=c:\somefile.txt
Run>macroA.exe /var1=%ON%

In this case var1 in macroA would be set to the "c:\somefile.txt"

This is because %ON% is valid syntax and a place holder for "c:\somefile.txt" inside of Macro Scheduler.

But it sounds like you want WOW to do this. If so then that is a question for WOW.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Tobias
Junior Coder
Posts: 22
Joined: Mon Jul 19, 2004 1:44 pm
Location: The Netherlands

Post by Tobias » Mon Feb 12, 2007 8:19 am

Marcus,

I'm not sure where the question lies. I think it is Macro Scheduler, but it could be WOW.

I know WOW can already send commands such as:

c:\dataProcessor.exe data_file1.dat

To make it more generic, %ON% replaces data_file1.dat. And that works fine too.

I also know I can use arguments with macros (like the Run>macroA.exe /var1=... in your example)

So the issue is: how to make my macro 'understand' that %ON% is a variable and that its value should be used.

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

Post by Marcus Tettmar » Mon Feb 12, 2007 8:22 am

Let me get this straight (!). %ON% is a variable belonging to WOW? or Macro Scheduler? What owns this ON variable? Who knows it's value?

What is calling the compiled macro? Another Macro Scheduler macro, or this thing called WOW?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Tobias
Junior Coder
Posts: 22
Joined: Mon Jul 19, 2004 1:44 pm
Location: The Netherlands

Post by Tobias » Mon Feb 12, 2007 9:02 am

Marcus,

I solved it.

During my posting here, I also discussed this with the developers of WOW. They tried a few things and come up with the solution. For some reason I have to use the following argument:
/var1=" %ON% "

Note the quotes and the whitespace before and after %ON%.

As only %ON% worked fine, I assumed MS-Pro read something wrong. I had tried various cominbations of quotes and whitespaces, but nothing seemed to work.

Sorry, my mistake.

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

Post by Marcus Tettmar » Mon Feb 12, 2007 9:05 am

Yes, when passing parameters to other applications, if there are spaces in those parameters then you will need quotes around them. That is a Windows thing.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

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

Tobias
Junior Coder
Posts: 22
Joined: Mon Jul 19, 2004 1:44 pm
Location: The Netherlands

Post by Tobias » Mon Feb 12, 2007 9:17 am

Actually there are no spaces in the values I tested successfully with. Values that do have spaces in them, work partially. Only the part till the first space is imported correctly, anything after it is ignored.
I'm not sure why, but it is sufficient for now (I tried adding more quotes, but that didn't do anything either)

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