Help with !var/!loop

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
Pwnsalad
Posts: 8
Joined: Sat Jun 16, 2012 6:57 am

Help with !var/!loop

Post by Pwnsalad » Sat Jun 16, 2012 7:02 am

Hello, it is very late where I am and this is my first post.
I will try not to break any rules, but no promises.

I am having an issue that I can't seem to find a cure for.
I would like to be able to control an if function, however, I'm not sure if iMacros for Firefox supports this.

If what I have previously state is true then is there a way for the script to determine the amount of loops it has ran? Or a way to set a !VAR to count the amount of loops then do something?

As I have said before I am having a little bit of trouble and the help would be greatly appreciated.
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Help with !var/!loop

Post by siniy » Sat Jun 16, 2012 7:58 am

Try imacros javascript interface. It's fairly simple. I can't write any decent script without it.

Name the script "loop.js" and run it as usual.

Code: Select all

var i =0;
while (i<5)
{
	iimDisplay(i);

    var macro;
    macro =  "CODE:";
    macro +=  "URL GOTO=http://google.com" + "\n";
    macro +=  "WAIT SECONDS=4" + "\n";
    iimPlay(macro);

	i++;
}
To convert iim script to js script use "imacros code creator"(google).
Pwnsalad
Posts: 8
Joined: Sat Jun 16, 2012 6:57 am

Re: Help with !var/!loop

Post by Pwnsalad » Sat Jun 16, 2012 2:13 pm

siniy wrote:Try imacros javascript interface. It's fairly simple. I can't write any decent script without it.

Name the script "loop.js" and run it as usual.

Code: Select all

var i =0;
while (i<5)
{
	iimDisplay(i);

    var macro;
    macro =  "CODE:";
    macro +=  "URL GOTO=http://google.com" + "\n";
    macro +=  "WAIT SECONDS=4" + "\n";
    iimPlay(macro);

	i++;
}
To convert iim script to js script use "imacros code creator"(google).

Wow, thanks a ton.
Is this compatible with iMacros for Firefox?
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Help with !var/!loop

Post by siniy » Sat Jun 16, 2012 2:25 pm

I believe it will work just in firefox.
Pwnsalad
Posts: 8
Joined: Sat Jun 16, 2012 6:57 am

Re: Help with !var/!loop

Post by Pwnsalad » Sat Jun 16, 2012 3:33 pm

siniy wrote:I believe it will work just in firefox.
Ok, just a few more questions (if you would be so kind) ;

I am not a big java coder but, from my understanding "while (i<5)" I am assuming 5 is the number of loops you want it to play.

I'm not sure what goes where "CODE:" is in the sample code

And I don't quite understand what the iimDisplay and iimPlay actually means.

Also, is this a IF - THEN command, what I would like it to do is when a !VAR in iMacros has 25(# of loops) to TAG a html element.

Sorry for all the questions, I don't quite understand java.
Hope to hear back from you!
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Help with !var/!loop

Post by siniy » Sat Jun 16, 2012 4:00 pm

I am not a big java coder but, from my understanding "while (i<5)" I am assuming 5 is the number of loops you want it to play.
Right, while (i<25) in your case.
I'm not sure what goes where "CODE:" is in the sample code
It is used in javascript interface to indicate beginning of imacros script.
And I don't quite understand what the iimDisplay and iimPlay actually means.
iimPlay starts imacros commands. iimDisplay just for debugging purpose.
Play with the script.
Pwnsalad
Posts: 8
Joined: Sat Jun 16, 2012 6:57 am

Re: Help with !var/!loop

Post by Pwnsalad » Sat Jun 16, 2012 4:27 pm

When I run your sample code

Code: Select all

var i =0;
while (i<25)
{
   iimDisplay(i);

    var macro;
    macro =  "CODE:";
    macro +=  "URL GOTO=http://google.com" + "\n";
    macro +=  "WAIT SECONDS=4" + "\n";
    iimPlay(macro);

   i++;
}
I get this error. "SyntaxError: unknown command: VAR, line: 1 (Error code: -910)"

Am I doing something wrong?
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Help with !var/!loop

Post by siniy » Sat Jun 16, 2012 5:36 pm

You filename must have .js extension, not .iim
Pwnsalad
Posts: 8
Joined: Sat Jun 16, 2012 6:57 am

Re: Help with !var/!loop

Post by Pwnsalad » Sat Jun 16, 2012 6:00 pm

I saved the file as loop.js
siniy
Posts: 118
Joined: Sat Nov 07, 2009 7:44 pm

Re: Help with !var/!loop

Post by siniy » Sat Jun 16, 2012 6:10 pm

Pwnsalad
Posts: 8
Joined: Sat Jun 16, 2012 6:57 am

Re: Help with !var/!loop

Post by Pwnsalad » Sat Jun 16, 2012 7:01 pm

Oh, wow.

I didn't realize that having them in the folder mattered.
I was just running the scripts off a folder on my desktop.

Thank you once again.
Post Reply