tag elements in frames with changing frame numbers

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
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
effykingly
Posts: 15
Joined: Fri Sep 26, 2014 11:17 am

tag elements in frames with changing frame numbers

Post by effykingly » Mon Sep 29, 2014 9:39 am

I am trying to tag elements in frames with changing frame numbers. I've tried Tom's example but when the .js file plays instead of the frame being a number I get FRAME F={{loop}} instead of FRAME F=1 or FRAME F=2. The tag I'm trying to get is "TAG POS=1 TYPE=SPAN ATTR=TXT:1<SP>Video".

My code is:

Code: Select all

     var macro;
    for (var i=0;i<=10;i++)
    {
            macro =  "CODE:";
            macro +=  "VERSION BUILD=8820413 RECORDER=FX" + "\n";
            macro +=  "SET !ERRORIGNORE YES" + "\n";
            macro +=  "TAB T=1" + "\n";
            macro +=  "URL GOTO=http://www.website.com/canon/[seriesname]/videos" + "\n";
            macro +=  "FRAME F={{fnum}}" + "\n";
            macro +=  "TAG POS=1 TYPE=SPAN ATTR=TXT:1<SP>Video" + "\n";
            macro +=  "TAG POS=1 TYPE=SPAN ATTR=TXT:(1<SP>of<SP>5) EXTRACT=TXT" + "\n";
            macro +=  "TAG POS=1 TYPE=SPAN ATTR=TXT:(1<SP>of<SP>10) EXTRACT=TXT" + "\n";
            macro +=  "TAG POS=1 TYPE=DIV ATTR=TXT:<SP>We<SP>are<SP>all<SP>out<SP>of<SP>offers.<SP>Please<SP>check<SP>back<SP>later<SP>for<SP>more. EXTRACT=TXT" + "\n";
            macro +=  "TAB T=2" + "\n";
            macro +=  "TAG POS=1 TYPE=DIV ATTR=TXT:Step<SP>5 EXTRACT=TXT" + "\n";
            macro +=  "TAG POS=1 TYPE=DIV ATTR=TXT:Step<SP>10 EXTRACT=TXT" + "\n";
            iimPlay(macro);
     var frame = 0;
  while (true)
       {
       iimSet("fnum", frame);
       if (iimPlay("macro") == 1)
          {
          break;
          }
       frame++;
       }
            if (iimGetLastExtract(1)== "(1 of 5)") {
                iimPlay('5.iim');
            } else if (iimGetLastExtract(2) == "(1 of 10)") {
                iimPlay('10.iim');
            } else if (iimGetLastExtract(4)== "Step 5" && iimGetLastExtract(5) != "Step 10") {
                iimPlay('5e.iim');
            } else if (iimGetLastExtract(4) == "Step 5" && iimGetLastExtract(5) == "Step 10") {
                iimPlay('10e.iim');
            } else if (iimGetLastExtract(3) == "We are all out of offers. Please check back later for more.") {
                iimPlay('none.iim');
            } else {
                iimPlay('single.iim');
            }

    }
chivracq
Posts: 8781
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: tag elements in frames with changing frame numbers

Post by chivracq » Mon Sep 29, 2014 4:40 pm

effykingly wrote:I am trying to tag elements in frames with changing frame numbers. I've tried Tom's example but when the .js file plays instead of the frame being a number I get FRAME F={{loop}} instead of FRAME F=1 or FRAME F=2. The tag I'm trying to get is "TAG POS=1 TYPE=SPAN ATTR=TXT:1<SP>Video".

My code is:

Code: Select all

     var macro;
    for (var i=0;i<=10;i++)
    {
            macro =  "CODE:";
            macro +=  "VERSION BUILD=8820413 RECORDER=FX" + "\n";
            macro +=  "SET !ERRORIGNORE YES" + "\n";
            macro +=  "TAB T=1" + "\n";
            macro +=  "URL GOTO=http://www.website.com/canon/[seriesname]/videos" + "\n";
            macro +=  "FRAME F={{fnum}}" + "\n";
            macro +=  "TAG POS=1 TYPE=SPAN ATTR=TXT:1<SP>Video" + "\n";
            macro +=  "TAG POS=1 TYPE=SPAN ATTR=TXT:(1<SP>of<SP>5) EXTRACT=TXT" + "\n";
            macro +=  "TAG POS=1 TYPE=SPAN ATTR=TXT:(1<SP>of<SP>10) EXTRACT=TXT" + "\n";
            macro +=  "TAG POS=1 TYPE=DIV ATTR=TXT:<SP>We<SP>are<SP>all<SP>out<SP>of<SP>offers.<SP>Please<SP>check<SP>back<SP>later<SP>for<SP>more. EXTRACT=TXT" + "\n";
            macro +=  "TAB T=2" + "\n";
            macro +=  "TAG POS=1 TYPE=DIV ATTR=TXT:Step<SP>5 EXTRACT=TXT" + "\n";
            macro +=  "TAG POS=1 TYPE=DIV ATTR=TXT:Step<SP>10 EXTRACT=TXT" + "\n";
            iimPlay(macro);
     var frame = 0;
  while (true)
       {
       iimSet("fnum", frame);
       if (iimPlay("macro") == 1)
          {
          break;
          }
       frame++;
       }
            if (iimGetLastExtract(1)== "(1 of 5)") {
                iimPlay('5.iim');
            } else if (iimGetLastExtract(2) == "(1 of 10)") {
                iimPlay('10.iim');
            } else if (iimGetLastExtract(4)== "Step 5" && iimGetLastExtract(5) != "Step 10") {
                iimPlay('5e.iim');
            } else if (iimGetLastExtract(4) == "Step 5" && iimGetLastExtract(5) == "Step 10") {
                iimPlay('10e.iim');
            } else if (iimGetLastExtract(3) == "We are all out of offers. Please check back later for more.") {
                iimPlay('none.iim');
            } else {
                iimPlay('single.iim');
            }

    }
chivracq wrote:
effykingly wrote:Any ideas on how tag elements in frames with changing frame numbers? I tried tom's example but I don't get a frame number.
I guess you had disabled BB Code in your previous Post, the Link is not working...:
http://forum.imacros.net/viewtopic.php?f=11&t=23436

EDIT: Oh, now it is, I guess you were still editing your Post... I will have a look...
Yep, but sorry, FCIM, I don't read and normally don't react/answer Threads where Full Config Info is missing...
I reacted in your previous Thread because 'Skippyto' had already answered but normally I ignore those Threads...
So you mention your FCI if you want me to dig into your Problem... (But I'm no JavaScript Guru...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
effykingly
Posts: 15
Joined: Fri Sep 26, 2014 11:17 am

Re: tag elements in frames with changing frame numbers

Post by effykingly » Tue Sep 30, 2014 8:23 am

My FCIM
iMacros: 10
Browser: Firefox 33
OS: Windows 7 Professional 64-bit SP 1
chivracq
Posts: 8781
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: tag elements in frames with changing frame numbers

Post by chivracq » Tue Sep 30, 2014 8:52 am

effykingly wrote:My FCIM
iMacros: 10
Browser: Firefox 33
OS: Windows 7 Professional 64-bit SP 1
OK.., good... (But "M" in "FCIM" is for "Missing", so you could have dropped it..., but never mind...)

Fouffff...!, I had a look at your Script, but I'm no JavaScript Guru and your Script is fairly complex and beyond my Knowledge (I merely only use JavaScript myself in my .iim Macros for 'EVAL()' Statements), with a 'for' Loop, with an embedded (or after the 'for Loop, I cannot really tell...) 'while' Loop and then many 'if else' Statements, but I think I notice that you call "macro += "FRAME F={{fnum}}" + "\n";" directly in your 'for' Loop but you declare your 'fnum' Variable only after, so 'fnum' is undefined... I'm surprised btw that you don't get some specific RuntimeError from iMacros, maybe because you use that complex Method with Macros created on the fly from a .js Script...

You should first make sure that your .iim Macro created on the fly works as a plain .iim Macro before using that Technique and use 'PROMPT' and 'alert()' to follow your Variables and debug your Script...
Last edited by chivracq on Tue Sep 30, 2014 11:05 am, edited 1 time in total.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
effykingly
Posts: 15
Joined: Fri Sep 26, 2014 11:17 am

Re: tag elements in frames with changing frame numbers

Post by effykingly » Tue Sep 30, 2014 10:52 am

chivracq wrote:
effykingly wrote:My FCIM
iMacros: 10
Browser: Firefox 33
OS: Windows 7 Professional 64-bit SP 1
OK.., good... (But "M" in "FCIM" is for "Missing", so you could have dropped it..., but never mind...)

Fouffff...!, I had a look at your Script, but I'm no JavaScript Guru and your Script is fairly complex and beyond my Knowledge (I merely only use JavaScript myself in my .iim Macros for 'EVAL()' Statements), with a 'for' Loop, with an embedded (or after the 'for Loop, I cannot really tell...) 'while' Loop and then many 'if else' Statements, but I think I notice that you call "macro += "FRAME F={{fnum}}" + "\n";" directly in your 'for' Loop but you declare your 'fnum' Variable only after, so 'fnum' is undefined... I'm surprised btw that you don't get some specific RuntimeError from iMacros, maybe because you use that complex Method with Macros created on the fly from a .js Script...

You should first make sure that your .iim Macro created on the fly works as a plain .iim Macro before using that Technique en use 'PROMPT' and 'alert()' to follow your Variables and debug your Script...
Thanks I'll try declaring fnum before using it in the macro and separating the code to see if I get the frame number.
effykingly
Posts: 15
Joined: Fri Sep 26, 2014 11:17 am

Re: tag elements in frames with changing frame numbers

Post by effykingly » Wed Oct 01, 2014 6:28 am

I tried it and got
BadParameter: expected F=<number> as parameter 1, line 2

Any ideas please?
User avatar
garyst1981
Posts: 125
Joined: Tue Jan 15, 2013 1:01 am
Location: Philadelphia, PA
Contact:

Re: tag elements in frames with changing frame numbers

Post by garyst1981 » Wed Oct 01, 2014 12:55 pm

what about using a wildcard

Code: Select all

macro +=  "FRAME F=*" + "\n";
www.gustavorivera.com.mx
skippyto
Posts: 108
Joined: Wed Aug 20, 2008 8:14 am

Re: tag elements in frames with changing frame numbers

Post by skippyto » Wed Oct 01, 2014 2:43 pm

Hi effykingly,

You can use PROMPT {{fnum}} to see what you have in your variable !

I won't be surprised if you read "undefined" as when you launch your macro for the first time, fnum is not set with iimSet...

You also can't launch anything with iimPlay("macro") in your while loop...

Skippyto
chivracq
Posts: 8781
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: tag elements in frames with changing frame numbers

Post by chivracq » Wed Oct 01, 2014 11:22 pm

effykingly wrote:I tried it and got
BadParameter: expected F=<number> as parameter 1, line 2

Any ideas please?
"it" is very vague in "I tried it..." if you don't post which updated/temporary Script(s) you used...!

Again, follow and debug your Variables with PROMPT/alert()... (like 'Skippyto' repeated as well...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
effykingly
Posts: 15
Joined: Fri Sep 26, 2014 11:17 am

Re: tag elements in frames with changing frame numbers

Post by effykingly » Wed Oct 15, 2014 2:08 pm

chivracq wrote:
effykingly wrote:I tried it and got
BadParameter: expected F=<number> as parameter 1, line 2

Any ideas please?
"it" is very vague in "I tried it..." if you don't post which updated/temporary Script(s) you used...!

Again, follow and debug your Variables with PROMPT/alert()... (like 'Skippyto' repeated as well...)
I tried running the frame check code before the macro.

Sorry for the vagueness. I tried declaring fnum before running the macro code. I simplified the code just to try testing the frame number checking.

Code: Select all

var frame = 0;
  while (true)
       {
       iimSet("fnum", frame);
       if (iimPlay("macro") == 1)
          {
          break;
          }
       frame++;
       }
var macro;
            macro +=  "TAB T=1" + "\n";
            macro +=  "URL GOTO=http://www.website.com/canon/[seriesname]/videos" + "\n";
            macro +=  "FRAME F={{fnum}}" + "\n";
            macro +=  "PROMPT {{fnum}}" + "\n";
            iimPlay(macro);
effykingly
Posts: 15
Joined: Fri Sep 26, 2014 11:17 am

Re: tag elements in frames with changing frame numbers

Post by effykingly » Wed Oct 15, 2014 2:21 pm

garyst1981 wrote:what about using a wildcard

Code: Select all

macro +=  "FRAME F=*" + "\n";
I tried using a wildcard and got BadParameter: expected F=<number> as parameter 1, line 3 (Error code: -911)

Code: Select all

var check;
check =  "CODE:";
check +=  "TAB T=1" + "\n";
check +=  "URL GOTO=http://www.website.com/canon/[seriesname]/videos" + "\n";
check +=  "FRAME F=*" + "\n";
check +=  "TAG POS=1 TYPE=SPAN ATTR=TXT:1<SP>Video" + "\n";
iimPlay(check);
kiko85
Posts: 16
Joined: Thu Jun 19, 2014 4:28 am

Re: tag elements in frames with changing frame numbers

Post by kiko85 » Thu May 21, 2015 6:56 am

Hi all.
I have found another way to fix problem with frames.
There is solution for it (js code).

Code: Select all

var macro; 
var macro1; 
var macro2; 
var a, b, c, d, e, f;
var NL = "\n";
var nd = "#EANF#"

//here u searching for frames one
macro =  "CODE:"; + NL; 
macro +=  "SET !EXTRACT_TEST_POPUP NO" + NL; 
macro +=  "FRAME F=1" + NL; 
macro +=  "SET !TIMEOUT_STEP 1" + NL; 
macro += "TAG POS=1 TYPE=* ATTR=* EXTRACT=TXT" + NL; 
iimPlay(macro)
//extract of your page = some variable (any expected)

a = iimGetLastExtract(1);
if (a!=nd)
{
macro1 =  "CODE:";
macro1 +=  "TAB T=1" + NL;
macro1 +=  "FRAME F=1" + NL;
macro1 += "" + NL;
macro1 += "" + NL;
macro1 += "" + NL;
// and Your macro continued here....
}

//now we searching for another frames
if (a==nd) 
{
macro =  "CODE:"; + NL; 
macro +=  "SET !EXTRACT_TEST_POPUP NO" + NL; 
macro +=  "FRAME F=2" + NL; 
macro +=  "SET !TIMEOUT_STEP 1" + NL; 
macro += "TAG POS=1 TYPE=* ATTR=* EXTRACT=TXT" + NL; 
iimPlay(macro)
b = iimGetLastExtract(1);

if (a==nd && (b!=nd)
{
macro1 =  "CODE:";
macro1 +=  "TAB T=1" + NL;
macro1 +=  "FRAME F=2" + NL;
macro1 += "" + NL;
macro1 += "" + NL;
macro1 += "" + NL;
// and Your macro continued here....
}

//and again and again..... for find frame

This method requires the repetition for each frame number.
But the spacing between each second only not every step for all code.
I hope that u understand me and sorry about my english :)
Post Reply