LOOP

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

LOOP

by TNT on Wed Sep 16, 2009 4:48 am

I posted this somewhere else but no one answered i am sorry for the Dub.

Can i define the number of times i want a scrip to repeat it self in side the macro file (iim file)?

Thanks,
TNT
 
Posts: 3
Joined: Tue Sep 15, 2009 6:24 am

Re: LOOP

by Marcia, Tech Support on Thu Sep 17, 2009 12:39 pm

Hello,

No problem, I deleted the other one. To your question:

TNT wrote:Can i define the number of times i want a scrip to repeat it self in side the macro file (iim file)?


No, you just have the option on the user interface ("Repeat Macro/Max:").
Regards,

Marcia
Marcia, Tech Support
 
Posts: 1058
Joined: Thu Jan 29, 2009 6:10 am

Re: LOOP

by josephconlin on Fri Sep 18, 2009 9:10 am

Marcia, iOpus wrote:Hello,

No problem, I deleted the other one. To your question:

TNT wrote:Can i define the number of times i want a scrip to repeat it self in side the macro file (iim file)?


No, you just have the option on the user interface ("Repeat Macro/Max:").

The other option is to write a script that can call your macro in a scripting language like VBS or Javascript. You can define the loop in the scripting language to be whatever size you need, and then have it call the macro.

Hope this helps.
josephconlin
 
Posts: 190
Joined: Tue Aug 05, 2008 7:38 pm

Re: LOOP

by asda123 on Sun Sep 20, 2009 1:00 pm

This is how to do a loop in JS, to change the amount of times it loops you change the section I have made bold and underlined. This script searches google for a random number.

var macro;
var jsLF = "\n";
var i, retcode, errtext;

for (i=0;i<=1000;i++) {

var randomnumber = Math.floor(Math.random()*1000);

/* Create the Macro */
macro = "CODE:";
macro += "URL GOTO=http://www.google.com" + jsLF;
macro += "TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:f ATTR=NAME:q CONTENT=" + randomnumber + jsLF;
macro += "TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:f ATTR=NAME:btnG&&VALUE:Google<SP>Search" + jsLF;
macro += "WAIT SECONDS=25" + jsLF;

retcode = iimPlay(macro);
if (retcode < 0) { // an error has occured
errtext = iimGetLastError();
alert(errtext);
}

if (retcode < 0) { // an error has occured
errtext = iimGetLastError();
alert(errtext);
break;
}

}
asda123
 
Posts: 4
Joined: Wed Jan 14, 2009 2:54 am

Re: LOOP

by rouge02 on Mon Sep 28, 2009 11:04 am

I'm getting the following error when I try to run this using iMacro

SyntaxError: unknown command: VAR at line 1

var i;
for (i=0;i<=5;i++)
{
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:GP_TEST=i
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Save<SP>(Alt+1)&&NAME:Save&&SRC:/cs/TEST/cache/PT_SAVE_1.gif
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Next<SP>in<SP>list<SP>(Alt+3)&&NAME:Next<SP>in<SP>List&&SRC:/cs/TEST/cache/PT_NEXTINLIST_1.gif
}


If I can get this loop working it would cut down 760 lines of code into 60 flat...
Why won't it let me declare the variable "i".
I commented out the "var i;", and it gave me the same error for the "for (i=0;i<=5;i++)"
SyntaxError: unknown command: FOR at line 2
rouge02
 
Posts: 6
Joined: Mon Sep 28, 2009 10:45 am

Re: LOOP

by ABooth on Tue Sep 29, 2009 9:11 am

rouge02 wrote:I'm getting the following error when I try to run this using iMacro

SyntaxError: unknown command: VAR at line 1

var i;
for (i=0;i<=5;i++)
{
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:GP_TEST=i
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Save<SP>(Alt+1)&&NAME:Save&&SRC:/cs/TEST/cache/PT_SAVE_1.gif
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Next<SP>in<SP>list<SP>(Alt+3)&&NAME:Next<SP>in<SP>List&&SRC:/cs/TEST/cache/PT_NEXTINLIST_1.gif
}


If I can get this loop working it would cut down 760 lines of code into 60 flat...
Why won't it let me declare the variable "i".
I commented out the "var i;", and it gave me the same error for the "for (i=0;i<=5;i++)"
SyntaxError: unknown command: FOR at line 2


What you're doing there is interspersing iMacros scripting language (all the TAG POS ... lines) with JavaScript. That won't work. It's like mixing Russian and Chinese in the same document and expecting the reader to know both languages and be able to determine when you switched from one to the other.

Try this: Open a text editor and paste in the following code: -

Javascript: ...\iMacros\Macros\multiPlay.js
Code: Select all
const iterations = 100; // Number of times to loop

for (var i=0; i<iterations; i++){
   iimSet('iteration', i );
   iimPlay('multiPlay');
}


Save this in your iMacros\Macros folder as multiPlay.js
NOTE the 'JS' file extension

Create a new text file and paste in the following code: -

iMacros scripting language: ...\iMacros\Macros\multiPlay.iim
Code: Select all
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:GP_TEST={{iteration}}
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Save<SP>(Alt+1)&&NAME:Save&&SRC:/cs/TEST/cache/PT_SAVE_1.gif
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Next<SP>in<SP>list<SP>(Alt+3)&&NAME:Next<SP>in<SP>List&&SRC:/cs/TEST/cache/PT_NEXTINLIST_1.gif


Save this in your iMacros\Macros folder as multiPlay.iim
NOTE the 'IIM' file extension

In your iMacros for Firefox plugin window, run the macro multiPlay.JS (not the iim)

The javascript executes the iMacros script and passes the iteration value to it.

You can rename the files to suit you, but remember to change the javascript file to execute the imacros script file with the name you gave it.

You can also change the number of loop iterations by changing

Loop 100 times
Code: Select all
const iterations = 100; // Number of times to loop


to something like this: -

Loop 50 times
Code: Select all
const iterations = 50; // Number of times to loop
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?
ABooth
 
Posts: 223
Joined: Mon Aug 10, 2009 9:25 am

Re: LOOP

by rouge02 on Thu Oct 01, 2009 7:49 am

Firstly thanks for your reply....
Secondly rofl @ Russian and Chinese... LoL

It would have been great if it allowed me to do just that...

If I'm reading your example correctly.. It solves the issue of my "i" increasing with each loop
But not actually looping the iMacro part of the code.

The first part of my script handles the first task, which only needs to be run once.
Then when it gets to this part;

Code: Select all
// with each loop i needs to be incremented by 1. i.e. 1-24 .. 3 lines of code to be executed 24 times, with i changing from 1-24 with each loop
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:GP_TEST=i
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Save<SP>(Alt+1)&&NAME:Save&&SRC:/cs/TEST/cache/PT_SAVE_1.gif
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Next<SP>in<SP>list<SP>(Alt+3)&&NAME:Next<SP>in<SP>List&&SRC:/cs/TEST/cache/PT_NEXTINLIST_1.gif


I want it to not only loop the iMacro script a specific number of times but with each loop the "i" must also increase by 1 (which is where your nice piece of code will come in handy).
I know iMacro has a general # of times to run script, but I don't want it looping the entire script. Only that section of code, once the "i" hits its target # then continue to end.

Again thanks for taking the time to reply
I'll see what I can come up with in the mean time, with what you've given me so far.
rouge02
 
Posts: 6
Joined: Mon Sep 28, 2009 10:45 am

Re: LOOP

by ABooth on Thu Oct 01, 2009 9:58 am

rouge02 wrote:Firstly thanks for your reply....
Secondly rofl @ Russian and Chinese... LoL

It would have been great if it allowed me to do just that...

If I'm reading your example correctly.. It solves the issue of my "i" increasing with each loop
But not actually looping the iMacro part of the code.

The first part of my script handles the first task, which only needs to be run once.
Then when it gets to this part;

Code: Select all
// with each loop i needs to be incremented by 1. i.e. 1-24 .. 3 lines of code to be executed 24 times, with i changing from 1-24 with each loop
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:GP_TEST=i
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Save<SP>(Alt+1)&&NAME:Save&&SRC:/cs/TEST/cache/PT_SAVE_1.gif
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Next<SP>in<SP>list<SP>(Alt+3)&&NAME:Next<SP>in<SP>List&&SRC:/cs/TEST/cache/PT_NEXTINLIST_1.gif


I want it to not only loop the iMacro script a specific number of times but with each loop the "i" must also increase by 1 (which is where your nice piece of code will come in handy).
I know iMacro has a general # of times to run script, but I don't want it looping the entire script. Only that section of code, once the "i" hits its target # then continue to end.

Again thanks for taking the time to reply
I'll see what I can come up with in the mean time, with what you've given me so far.


It will do what you want, because the Javascript piece has the loop that increments the {{iteration}} variable each time.

Here's a step by step breakdown of the javascript code

A setting for the maximum number of times the macro will be run. E.G. 100 times
Code: Select all
const iterations = 100; // Number of times to loop


Start a loop from 0 to iterations value -1, e.g 0 to (100 - 1) = 99
Code: Select all
for (var i=0; i<iterations; i++){


Create an iMacros variable called {{iteration}} with a value set to the current increment value from 0 to 99, that will be passed to the next execution of your iMacros script.
Code: Select all
   iimSet('iteration', i );


Play the macro once per loop iteration, where it gets passed the new loop iteration variable with a value from 0 to 99
Code: Select all
   iimPlay('multiPlay');


End the block of code that gets looped
Code: Select all
}


So the macro multiPlay.iim will get run 100 times and will be passed a value initially 0, but each time, gets incremented 'til the loop reaches 99


Note: If you want to go from 1 to 100 instead of 0 to 99, simply change this line of code from: -
Code: Select all
   iimSet('iteration', i );


To:-
Code: Select all
   iimSet('iteration', i  + 1);
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?
ABooth
 
Posts: 223
Joined: Mon Aug 10, 2009 9:25 am

Re: LOOP

by rouge02 on Thu Oct 01, 2009 1:19 pm

Ok so I understand that, but let me give you the bigger picture here..
This first piece of code starts off my iMacro script...

Code: Select all
VERSION BUILD=6240709 RECORDER=FX
TAB T=1

'TESTING URL
URL GOTO=http://testing.serv1.ttl:7110/psp/TESTING/c/MANAGE_PROCESS_(GBL).GP_RUNCTL.GBL

'SEARCH testing TEST RUN CONTROL
FRAME F=3
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:PRCSRUNCNTL_RUN_CNTL_ID CONTENT=testing
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Search<SP>(Alt+1)&&NAME:Search&&SRC:/cs/TESTING/cache/PT_SEARCH_1.gif
WAIT SECONDS=2

'SELECT testing01 FROM SEARCH RESULTS
TAG POS=1 TYPE=A ATTR=CLASS:PSSRCHRESULTSODDROW&&TABINDEX:34&&HREF:javascript:<SP>submitAction_win0(document,'win0','#ICRow12');

Once complete it continues to the following, and this entire section of code needs to be looped 24 times.
And "i" needs to be changed from 1 - 24 with each loop.. <=which i understand how to do based on what you've given me
Code: Select all
'ENTER CALENDAR GROUP ID
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:GP_RUNCTL_CAL_RUN_ID CONTENT=TESTING009
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:absmiddle&&ALT:Look<SP>up<SP>Calendar<SP>Group<SP>ID<SP>(Alt+5)&&SRC:/cs/TESTING/cache/PT_PROMPT_LOOKUP_1.gif
WAIT SECONDS=2
TAG POS=1 TYPE=A ATTR=CLASS:PSSRCHRESULTSODDROW&&TABINDEX:21&&HREF:javascript:<SP>submitAction_win0(document,'win0','#ICRow0');&&NAME:SEARCH_RESULT1

'SELECT IDENTIFY + CALCULATE + RECALCULATE
FRAME F=3
WAIT SECONDS=1
TAG POS=1 TYPE=LABEL ATTR=CLASS:PSCHECKBOX&&FOR:GP_RUNCTL_RUN_IDNT_IND
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:win0 ATTR=ID:GP_RUNCTL_RUN_IDNT_IND CONTENT=YES
WAIT SECONDS=1
TAG POS=1 TYPE=LABEL ATTR=CLASS:PSCHECKBOX&&FOR:GP_RUNCTL_RUN_CALC_IND$24$
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:win0 ATTR=ID:GP_RUNCTL_RUN_CALC_IND$24$ CONTENT=YES
WAIT SECONDS=1
TAG POS=1 TYPE=LABEL ATTR=CLASS:PSCHECKBOX&&FOR:GP_RUNCTL_RUN_RECALC_ALL_IND
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:win0 ATTR=ID:GP_RUNCTL_RUN_RECALC_ALL_IND CONTENT=YES
WAIT SECONDS=1

'STREAM #1 of 24
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:GP_RUNCTL_STRM_NUM CONTENT=i

'SAVE PARAMETERS
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Save<SP>(Alt+1)&&NAME:Save&&SRC:/cs/TESTING/cache/PT_SAVE_1.gif

WAIT SECONDS=2

'GO TO  NEXT IN LIST
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Next<SP>in<SP>list<SP>(Alt+3)&&NAME:Next<SP>in<SP>List&&SRC:/cs/TESTING/cache/PT_NEXTINLIST_1.gif

'END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-

'NOTE AT THE POINT WHERE IT SAYS 'STREAM #1 of 24 THAT CODE POSTED WILL COME INTO PLAY HERE TO INCREASE
THE VALUE OF i BY 1 AT EACH LOOP


So I was thinking either I separate the first piece of code from the second and insert a call to the second piece of code so that
I can use iMacro's Repeat, to repeat the whole of the second macro, X amount of times.

Or figure out how to loop the 2nd piece of code 24 times.. and still
use your code to change the value of i from 1 - 24 respectively.
rouge02
 
Posts: 6
Joined: Mon Sep 28, 2009 10:45 am

Re: LOOP

by ABooth on Thu Oct 01, 2009 8:40 pm

That can be easily achieved with a small change.

Separate the part before the loop and save it as preLoop.iim
Code: Select all
VERSION BUILD=6240709 RECORDER=FX
TAB T=1

'TESTING URL
URL GOTO=http://testing.serv1.ttl:7110/psp/TESTING/c/MANAGE_PROCESS_(GBL).GP_RUNCTL.GBL

'SEARCH testing TEST RUN CONTROL
FRAME F=3
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:PRCSRUNCNTL_RUN_CNTL_ID CONTENT=testing
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Search<SP>(Alt+1)&&NAME:Search&&SRC:/cs/TESTING/cache/PT_SEARCH_1.gif
WAIT SECONDS=2

'SELECT testing01 FROM SEARCH RESULTS
TAG POS=1 TYPE=A ATTR=CLASS:PSSRCHRESULTSODDROW&&TABINDEX:34&&HREF:javascript:<SP>submitAction_win0(document,'win0','#ICRow12');

'ENTER CALENDAR GROUP ID
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:GP_RUNCTL_CAL_RUN_ID CONTENT=TESTING009
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:absmiddle&&ALT:Look<SP>up<SP>Calendar<SP>Group<SP>ID<SP>(Alt+5)&&SRC:/cs/TESTING/cache/PT_PROMPT_LOOKUP_1.gif
WAIT SECONDS=2
TAG POS=1 TYPE=A ATTR=CLASS:PSSRCHRESULTSODDROW&&TABINDEX:21&&HREF:javascript:<SP>submitAction_win0(document,'win0','#ICRow0');&&NAME:SEARCH_RESULT1

'SELECT IDENTIFY + CALCULATE + RECALCULATE
FRAME F=3
WAIT SECONDS=1
TAG POS=1 TYPE=LABEL ATTR=CLASS:PSCHECKBOX&&FOR:GP_RUNCTL_RUN_IDNT_IND
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:win0 ATTR=ID:GP_RUNCTL_RUN_IDNT_IND CONTENT=YES
WAIT SECONDS=1
TAG POS=1 TYPE=LABEL ATTR=CLASS:PSCHECKBOX&&FOR:GP_RUNCTL_RUN_CALC_IND$24$
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:win0 ATTR=ID:GP_RUNCTL_RUN_CALC_IND$24$ CONTENT=YES
WAIT SECONDS=1
TAG POS=1 TYPE=LABEL ATTR=CLASS:PSCHECKBOX&&FOR:GP_RUNCTL_RUN_RECALC_ALL_IND
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:win0 ATTR=ID:GP_RUNCTL_RUN_RECALC_ALL_IND CONTENT=YES
WAIT SECONDS=1


Then save the loop section as loopSection.iim Note: I replaced CONTENT=i with CONTENT={{i}} because {{i}} is now passed from JavaScript to the iMacros script
Code: Select all
'STREAM #1 of 24
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:GP_RUNCTL_STRM_NUM CONTENT={{i}}


Then save the rest as postLoop.iim
Code: Select all
'SAVE PARAMETERS
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Save<SP>(Alt+1)&&NAME:Save&&SRC:/cs/TESTING/cache/PT_SAVE_1.gif

WAIT SECONDS=2

'GO TO  NEXT IN LIST
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Next<SP>in<SP>list<SP>(Alt+3)&&NAME:Next<SP>in<SP>List&&SRC:/cs/TESTING/cache/PT_NEXTINLIST_1.gif

'END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-



Then modify your JavaScript to run all 3 iMacros
Code: Select all
const iterations = 24; // Number of times to loop

//Run the bit before the loop
iimPlay('preLoop');

//Start Of Loop
for (var i=0; i<iterations; i++){
   iimSet('i', i + 1); //increment {{i}} each time 1 to 24
   iimPlay('loopSection');
} // End Of Loop

// Run the bit after the loop
iimPlay('postLoop');


If everything from 'STREAM #1 of 24 onwards is needed in the loop, do this

Separate the part before the loop and save it as preLoop.iim
Code: Select all
VERSION BUILD=6240709 RECORDER=FX
TAB T=1

'TESTING URL
URL GOTO=http://testing.serv1.ttl:7110/psp/TESTING/c/MANAGE_PROCESS_(GBL).GP_RUNCTL.GBL

'SEARCH testing TEST RUN CONTROL
FRAME F=3
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:PRCSRUNCNTL_RUN_CNTL_ID CONTENT=testing
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Search<SP>(Alt+1)&&NAME:Search&&SRC:/cs/TESTING/cache/PT_SEARCH_1.gif
WAIT SECONDS=2

'SELECT testing01 FROM SEARCH RESULTS
TAG POS=1 TYPE=A ATTR=CLASS:PSSRCHRESULTSODDROW&&TABINDEX:34&&HREF:javascript:<SP>submitAction_win0(document,'win0','#ICRow12');

'ENTER CALENDAR GROUP ID
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:GP_RUNCTL_CAL_RUN_ID CONTENT=TESTING009
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:absmiddle&&ALT:Look<SP>up<SP>Calendar<SP>Group<SP>ID<SP>(Alt+5)&&SRC:/cs/TESTING/cache/PT_PROMPT_LOOKUP_1.gif
WAIT SECONDS=2
TAG POS=1 TYPE=A ATTR=CLASS:PSSRCHRESULTSODDROW&&TABINDEX:21&&HREF:javascript:<SP>submitAction_win0(document,'win0','#ICRow0');&&NAME:SEARCH_RESULT1

'SELECT IDENTIFY + CALCULATE + RECALCULATE
FRAME F=3
WAIT SECONDS=1
TAG POS=1 TYPE=LABEL ATTR=CLASS:PSCHECKBOX&&FOR:GP_RUNCTL_RUN_IDNT_IND
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:win0 ATTR=ID:GP_RUNCTL_RUN_IDNT_IND CONTENT=YES
WAIT SECONDS=1
TAG POS=1 TYPE=LABEL ATTR=CLASS:PSCHECKBOX&&FOR:GP_RUNCTL_RUN_CALC_IND$24$
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:win0 ATTR=ID:GP_RUNCTL_RUN_CALC_IND$24$ CONTENT=YES
WAIT SECONDS=1
TAG POS=1 TYPE=LABEL ATTR=CLASS:PSCHECKBOX&&FOR:GP_RUNCTL_RUN_RECALC_ALL_IND
TAG POS=1 TYPE=INPUT:CHECKBOX FORM=NAME:win0 ATTR=ID:GP_RUNCTL_RUN_RECALC_ALL_IND CONTENT=YES
WAIT SECONDS=1


Then save the loop section as loopSection.iim Note: I replaced CONTENT=i with CONTENT={{i}} because {{i}} is now passed from JavaScript to the iMacros script
Code: Select all
'STREAM #1 of 24
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:win0 ATTR=ID:GP_RUNCTL_STRM_NUM CONTENT={{i}}

'SAVE PARAMETERS
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Save<SP>(Alt+1)&&NAME:Save&&SRC:/cs/TESTING/cache/PT_SAVE_1.gif

WAIT SECONDS=2

'GO TO  NEXT IN LIST
TAG POS=1 TYPE=IMG ATTR=BORDER:0&&ALIGN:middle&&ALT:Next<SP>in<SP>list<SP>(Alt+3)&&NAME:Next<SP>in<SP>List&&SRC:/cs/TESTING/cache/PT_NEXTINLIST_1.gif

'END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-OF-STREAM~END-



Then modify your JavaScript to run both iMacros
Code: Select all
const iterations = 24; // Number of times to loop

//Run the bit before the loop
iimPlay('preLoop');

//Start Of Loop
for (var i=0; i<iterations; i++){
   iimSet('i', i + 1); //increment {{i}} each time 1 to 24
   iimPlay('loopSection');
} // End Of Loop

Note: No post loop section.
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?
ABooth
 
Posts: 223
Joined: Mon Aug 10, 2009 9:25 am

Re: LOOP

by ng.tinyreef on Mon May 10, 2010 10:34 am

Great Topic!

Quick question though


How would I tell the script to loop between a number range

ie.


I want to loop between lines 25-40 on my csv file
is there an easy way to tell the javascript how to do this?
ng.tinyreef
 
Posts: 17
Joined: Thu Oct 22, 2009 1:29 pm

Re: LOOP

by rouge02 on Mon May 10, 2010 8:21 pm

Hi ng.tinyreef, can we get a little more info about your csv file. off the bat i'm thinking for you to just put lines 25-40 in a separate csv file..
or just use the { } brackets to isolate that part of the script, but as i've learned with my inatial loop issue it's never quite that simple..


as my boy Murphy would say;
--every solution breeds new problems
--there's always one more bug
rouge02
 
Posts: 6
Joined: Mon Sep 28, 2009 10:45 am

Re: LOOP

by MattBell7 on Fri May 14, 2010 5:28 am

Code: Select all
for (var i=25; i<=40; i++){
   iimSet('i', i); //increment {{i}} each time 25 to 40
   iimPlay('loopSection');
}


tada
MattBell7
 
Posts: 628
Joined: Thu Nov 26, 2009 4:07 am
Location: United Kingdom

Re: LOOP

by rouge02 on Fri May 14, 2010 4:27 pm

I don't think that is quite what he had in mind.

He said;
ng.tinyreef wrote:....cut....
I want to loop between lines 25-40 on my csv file
is there an easy way to tell the javascript how to do this?


Looping lines of script is another matter altogether.
As i was corrected earlier for mixing iMacro script and javascript;

ABooth wrote:...cut... What you're doing there is interspersing iMacros scripting language (all the TAG POS ... lines) with JavaScript. That won't work. It's like mixing Russian and Chinese in the same document and expecting the reader to know both languages and be able to determine when you switched from one to the other.
rouge02
 
Posts: 6
Joined: Mon Sep 28, 2009 10:45 am

Re: LOOP

by xNeroX on Sat Apr 02, 2011 9:18 pm

A neat trick to script a loop into the macro itself. use this
SET !LOOP -500
(This will trick the Macro into repeating 500 times)
xNeroX
 
Posts: 1
Joined: Sat Apr 02, 2011 9:14 pm

Next

Return to iMacros for Firefox

Who is online

Users browsing this forum: No registered users and 6 guests

cron

Website Monitoring