SCRIPTING INTERFACE - iimPlay() function

Discussions and Tech Support specific to the iMacros Firefox add-on.
Forum rules
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
Kamma
Posts: 4
Joined: Sun Jun 24, 2007 8:52 pm

SCRIPTING INTERFACE - iimPlay() function

Post by Kamma » Sun Jun 24, 2007 9:03 pm

Hi everyone!
I have some problems with code interpretation by iimPlay function.
Look at this example code:

Code: Select all

var MyMacroCode
var jsNewLine="\n"

MyMacroCode = "CODE:"
MyMacroCode = MyMacroCode+"TAB T=1" + jsNewLine    
MyMacroCode = MyMacroCode+"FRAME F=3" + jsNewLine  
MyMacroCode = MyMacroCode+"EXTRACT POS=1 TYPE=OPTION  CONTENT=TXT*"

iimPlay(MyMacroCode);

var i;
i = iimGetLastExtract();
iimDisplay(i);
It works good. User sees the value of extracted data and the data is right.

Look at the second code, which should do the same thing, but I modified code structure a little:

Code: Select all

iimPlay("CODE:TAB T=1");
iimPlay("CODE:FRAME F=3");
iimPlay("CODE:EXTRACT POS=1 TYPE=OPTION  CONTENT=TXT*");

var i;
i = iimGetLastExtract();
iimDisplay(i);
This code doesn't extract data from option tag. Information dialog contains only #EANF#!
Could you explain me why?
User avatar
Tech Support
Posts: 4947
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Sun Jun 24, 2007 10:44 pm

Thanks for the interesting quesition. Here is the solution:

The main difference between both code examples is: In the first example you have one macro with three lines, and in the second example you have three macros with one line each!

That in itself no problem, but when the third macro starts the FRAME F=3 setting from the second macro is no longer available and iMacros uses the default value (F=1). Therefore the extraction command refers to the wrong frame and fails.

In this example TAB T=1 makes no problem because T=1 is the default value. But if you would need T=2 than you need to add it to the macro with the extract command, too.

During subsequent macro runs all macro related variables are reset. In contrast the web browser context is preserved, so the second macro continues where the first macro stopped. As an example, the following separation would be ok, because each line is independent.

Code: Select all

iimPlay ("CODE:URL GOTO=http://www.iopus.com/imacros/demo/v6/f1/form.asp")
iimPlay ("CODE:TAG TYPE=INPUT:TEXT FORM=NAME:TestForm ATTR=NAME:Name CONTENT=Tom<SP>Tester")
iimPlay ("CODE:TAG TYPE=SELECT FORM=NAME:TestForm ATTR=NAME:main CONTENT=$Pizza")
Kamma
Posts: 4
Joined: Sun Jun 24, 2007 8:52 pm

Post by Kamma » Tue Jun 26, 2007 6:37 pm

Thanks for answer. I realised why it doesn't wok well a few hours later after my post publication.
Post Reply