Carry variable to next macro?

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
iMacros EOL - Attention!

The renewal maintenance has officially ended for Progress iMacros effective November 20, 2023 and all versions of iMacros are now considered EOL (End-of-Life). The iMacros products will no longer be supported by Progress (aside from customer license issues), and these forums will also no longer be moderated from the Progress side.

Thank you again for your business and support.

Sincerely,
The Progress Team

Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
mgoblue4
Posts: 8
Joined: Tue Dec 29, 2009 6:39 pm

Carry variable to next macro?

Post by mgoblue4 » Tue Dec 29, 2009 6:52 pm

I am pretty new to this iMacro stuff so please speak in dumb person language.
I am trying to set a variable at the beginning of a string of macros via a prompt window as such...

Code: Select all

PROMPT Please<SP>enter<SP>STORE<SP>ID !VAR1
Then this is the JS file that I am using to run the macros back to back.

Code: Select all

ret = iimPlay("macro1")
ret = iimPlay("macro2")
Macro1 holds the prompt to set the variable.
ABooth
Posts: 223
Joined: Mon Aug 10, 2009 4:25 pm

Re: Carry variable to next macro?

Post by ABooth » Tue Dec 29, 2009 9:40 pm

iMacro code in macro1

Code: Select all

SET !EXTRACT NULL
PROMPT Please<SP>enter<SP>STORE<SP>ID !EXTRACT
Javascript macro

Code: Select all

iimPlay("macro1");

var value = iimGetLastExtract();
iimSet ( "storeId", value );

iimPlay("macro2");
Variable use in macro2: {{storeId}}
iMacros for Firefox supports JavaScript Macros (Scripting)
JavaScript supports Java via LiveConnect

Therefore: You can write powerful macros with iMacros for Firefox. Have a look at this one

Post feature requests here. Maybe one day, they'll pin it?
mgoblue4
Posts: 8
Joined: Tue Dec 29, 2009 6:39 pm

Re: Carry variable to next macro?

Post by mgoblue4 » Tue Dec 29, 2009 10:03 pm

Thank you very much, however I am getting an error message saying that the PROMPT line is not in the correct format?
ABooth
Posts: 223
Joined: Mon Aug 10, 2009 4:25 pm

Re: Carry variable to next macro?

Post by ABooth » Wed Dec 30, 2009 3:47 pm

mgoblue4 wrote:Thank you very much, however I am getting an error message saying that the PROMPT line is not in the correct format?
Ah, yes. Prompt only allows !VAR1, !VAR2 and !VAR3, so you would need to do this instead: -

iMacro code in macro1

Code: Select all

PROMPT Please<SP>enter<SP>STORE<SP>ID !VAR1
SET !EXTRACT {{!VAR1}}
Javascript macro

Code: Select all

iimPlay("macro1");

var value = iimGetLastExtract();
iimSet ( "storeId", value );

iimPlay("macro2");
Variable use in macro2: {{storeId}}
iMacros for Firefox supports JavaScript Macros (Scripting)
JavaScript supports Java via LiveConnect

Therefore: You can write powerful macros with iMacros for Firefox. Have a look at this one

Post feature requests here. Maybe one day, they'll pin it?
mgoblue4
Posts: 8
Joined: Tue Dec 29, 2009 6:39 pm

Re: Carry variable to next macro?

Post by mgoblue4 » Wed Dec 30, 2009 4:28 pm

Awesome! Works great except what if I want to play another macro after macro2 and use the same variable in this macro? Something like this...

Code: Select all

iimPlay("macro1");

var value = iimGetLastExtract();
iimSet ( "storeId", value );

iimPlay("macro2");
iimPlay("macro3");
iimPlay("macro4");
etc......
Each one of these macros will use the same storeId variable that is set but I do not want to have to set it every time as it will be the same value throughout.

Thanks for your help!
ABooth
Posts: 223
Joined: Mon Aug 10, 2009 4:25 pm

Re: Carry variable to next macro?

Post by ABooth » Wed Dec 30, 2009 5:34 pm

You can extract and store it once in JavaScript, but each call to iimPlay, disposes of all set iMacro variables, so {{storeId}} needs setting before each macro call.

Code: Select all

iimPlay("macro1");

var value = iimGetLastExtract();

iimSet ( "storeId", value );
iimPlay("macro2");

iimSet ( "storeId", value );
iimPlay("macro3");

iimSet ( "storeId", value );
iimPlay("macro4");
iMacros for Firefox supports JavaScript Macros (Scripting)
JavaScript supports Java via LiveConnect

Therefore: You can write powerful macros with iMacros for Firefox. Have a look at this one

Post feature requests here. Maybe one day, they'll pin it?
mgoblue4
Posts: 8
Joined: Tue Dec 29, 2009 6:39 pm

Re: Carry variable to next macro?

Post by mgoblue4 » Wed Dec 30, 2009 5:47 pm

Awesome! Thank you soooo much for your help! Have a wonderful new year.
Post Reply