Loop, can Imacros tell when your at the end of file?

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
jetus
Posts: 4
Joined: Thu Mar 06, 2008 2:07 am

Loop, can Imacros tell when your at the end of file?

Post by jetus » Wed Mar 26, 2008 12:36 pm

If I am using the following command,
SET !DATASOURCE_LINE {{!LOOP}}

and I set my Play(Loop) dialog box to a number larger than my file, how can Firefox Imacros tell if you are at the end of the file, and stop? It just continues to run on the last line of my file.
tampe125
Posts: 90
Joined: Sat Jan 26, 2008 8:27 pm

Re: Loop, can Imacros tell when your at the end of file?

Post by tampe125 » Wed Mar 26, 2008 10:14 pm

yes, you can, but have to use a javascript file. i had your same problem and i've done a script for that.
here you are:
1) first make your macro. you have to use some variable that you'll set outside, in the js file:

Code: Select all

CMDLINE !DATASOURCE [[your datasource path]]
SET !VAR1
SET !DATASOURCE_COLUMNS [[your number of columns]]
SET !DATASOURCE_LINE {{!VAR1}}           //use this instead of LOOP
TAB T=1
URL GOTO={{!COL1}}
TAB T=2
URL GOTO={{!COL2}}
SET !EXTRACTADD {{!URLCURRENT}}       //VERY important: it will say if you're at the end
2) then create a new .js file. i've seen that when the lines are empty, in the url bar appears this: "chrome://browser/content/browser.xul". so i've thought to use that to make imacro stops.
this is the code:

Code: Select all

var a
var i
var s

for (i=1; i<=1000; i++)           //as you can see,this is a VERY HIGH range (until 1000)
{
   iimSet('-var_VAR1', ''+i);     //here we will set the variable VAR1 used into the macro
   a = iimPlay('[[your macro name]]')
   s = iimGetLastExtract();
   if (s == 'chrome://browser/content/browser.xul#EANF#' || s == 'chrome://browser/content/browser.xul') break;
}
this is all. i've set up imacro to stop even if he founds the #EANF# value. if you don't want that, simply delete the s == 'chrome://browser/content/browser.xul#EANF#' || part from the "if" statement.
tell if it works with you.

Ciauz

p.s. since i'm only a noob, please any of the more experience users can tell me if everything is alright of if i can make any improvement? thanks
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Re: Loop, can Imacros tell when your at the end of file?

Post by Tech Support » Thu Mar 27, 2008 12:11 am

tampe125, that is a very clever solution :D

Another approach is to check the iimPlay return code: It is <0 if an error occurred (such as end of file is reached).
tampe125
Posts: 90
Joined: Sat Jan 26, 2008 8:27 pm

Re: Loop, can Imacros tell when your at the end of file?

Post by tampe125 » Thu Mar 27, 2008 9:28 am

i have just tried this code:

Code: Select all

for (i=1; i<=60; i++)
{
   iimSet('-var_VAR1', ''+i);
   a = iimPlay(macro)
   if (a < 0) break;
}
nothing happened. imacros continued to read the file.. :roll:
where is the error?
giorgio79
Posts: 80
Joined: Thu Oct 02, 2008 8:34 am

Re: Loop, can Imacros tell when your at the end of file?

Post by giorgio79 » Wed Dec 31, 2008 10:26 am

Thanks tampe125 for this tip, unfortunately the xul stuff did not detect the end of my csv file...Any ideas?
Share your imacros easily http://www.sharemacro.com/imacro-directory
Internet Marketing imacros http://www.sharemacro.com
venn99
Posts: 9
Joined: Fri Feb 18, 2011 5:52 pm

Re: Loop, can Imacros tell when your at the end of file?

Post by venn99 » Fri Feb 18, 2011 10:07 pm

i need a solution to this as well, but i am not sure how to intgrate js in with a macro in firefox?
Download
Posts: 89
Joined: Thu Jun 02, 2011 2:08 pm

Re: Loop, can Imacros tell when your at the end of file?

Post by Download » Thu Feb 21, 2013 8:51 am

please emplane it
Post Reply