Dynamic Frame Tracking

Discussions and Tech Support related to website data extraction, screen scraping and data mining using iMacros.
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
azbob
Posts: 85
Joined: Mon Sep 21, 2009 6:16 pm

Re: Dynamic Frame Tracking

Post by azbob » Thu Jun 15, 2017 1:24 am

FYI here is my final copy of the Frame Tracker...

Code: Select all

iimPlay('++AATEST_PRE_LOOP.iim');
//declarations
var fnb=(14);

var find_number =  "CODE:";
find_number += "SET !ERRORIGNORE YES" + "\n";
find_number += "SET !EXTRACT NULL" + "\n";
find_number +=  "FRAME F={{Frame_Nb}}" + "\n";
find_number +=  "SET !TIMEOUT_STEP 0" + "\n";
find_number +=  "TAG POS=1 TYPE=TD ATTR=TXT:High" + "\n";
find_number +=  "TAG POS=R1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT" + "\n"; 

for(; fnb <= 18; fnb++){
	iimSet("Frame_Nb",fnb);
	iimPlay(find_number);
	var frame_valid = iimGetLastExtract(1);


//if extract was frame number than save frame number and play rest of macro
	if (frame_valid !== "#EANF#")
     	{
	iimSet("Frame_Nb",fnb);
	break;
	}
	
	}
iimPlay('++AATEST_POST_LOOP.iim');
Thanks for all your help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Dynamic Frame Tracking

Post by chivracq » Thu Jun 15, 2017 4:47 am

azbob wrote:Here is link to files.

https://www.dropbox.com/sh/xjdshdwxrqpm ... K2yCa?dl=0

I hope I created them correctly.
Let me know if you need anything else.
Thanks,
Bob
OK, was a bit of a hassle as one single Zip File would have been easier and I feared for a while I would need to download one by one the 278 Files (278...!?, for 1 Web-Page...!?, WTF...!?) but DropBox via FF53 managed to zip everything by itself...

But pfff..., once opened and a bit analyzed, this Site is so ridiculously bad designed with 4 Levels of Nested Frames that the Method I had in mind (which would work for 1 Level) would quickly become very cumbersome I fear and would then take much longer than your Method with a '.js' Loop.
And yep..., they all do have an ID/Name, but the same ID is reused at different Nested Levels, so iMacros cannot use it as it doesn't have a 'POS' Parameter for the 'FRAME' Command like it has for the 'TAG' Command. I'm actually nearly a bit surprised that iMacros is still able to locate all those Frames by their Number without being mixed up...! 8)

The only "good Design" of this Site is the Size of the Pictures, 51 Pictures = only 1.3Mb (=> about 25Kb per Picture, which is very neat), but the whole Page is 8Mb heavy, which is a bit ridiculous...!, I hope you are not on Mobile with a limited Data Amount, ah-ah...! But the Site didn't looked designed for Mobile anyway, the Frames would lose track constantly of my Screen Size and overlap each other after each iMacros Panel Open/Close Toggle...
azbob wrote:FYI here is my final copy of the Frame Tracker...

Code: Select all

iimPlay('++AATEST_PRE_LOOP.iim');
//declarations
var fnb=(14);

var find_number =  "CODE:";
find_number += "SET !ERRORIGNORE YES" + "\n";
find_number += "SET !EXTRACT NULL" + "\n";
find_number +=  "FRAME F={{Frame_Nb}}" + "\n";
find_number +=  "SET !TIMEOUT_STEP 0" + "\n";
find_number +=  "TAG POS=1 TYPE=TD ATTR=TXT:High" + "\n";
find_number +=  "TAG POS=R1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT" + "\n"; 

for(; fnb <= 18; fnb++){
	iimSet("Frame_Nb",fnb);
	iimPlay(find_number);
	var frame_valid = iimGetLastExtract(1);


//if extract was frame number than save frame number and play rest of macro
	if (frame_valid !== "#EANF#")
     	{
	iimSet("Frame_Nb",fnb);
	break;
	}
	
	}
iimPlay('++AATEST_POST_LOOP.iim');
Thanks for all your help...
Yep, glad I could help... :D
A few little "things" could still be improved in your Script but "we" won't touch anything as it works now, I'm afraid you might start a new "Challenge" otherwise, ah-ah...! :shock: :wink:

(Now you can share your Sol on SOF as well, and you could mention your FCI there as well... :idea:
And hum, @Shugar's Suggestion is correct in general but doesn't play a role in your Case as the 3 Vars you define in your '.js' Script with 'iimSet()' are not used in your 'find_number' on-the-fly Macro and we can't tell if you use them or not in your '++AATEST_POST_LOOP.iim' Macro, so moving them won't change anything...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
azbob
Posts: 85
Joined: Mon Sep 21, 2009 6:16 pm

Re: Dynamic Frame Tracking

Post by azbob » Fri Jun 16, 2017 12:19 am

Well most of those iimSets were just for testing as I would pass into post loop than prompt for result..so yea not important.

Here is a follow on question. I am now integrating find_number into existing macros by creating .js files that call .iim files. Following the format of iimPlay(x.iim), run find_number .js, passing Frame_Nb to next iimPlay(y.iim).
In this instance imacros file named A_SVS_TAX_DATA.js.
In first x.iim in file I have a prompt for address that I store in !VAR1 that I want to access in y.iim to pass to a web page.
So what I tried to do was create a csv file in x.iim:

Code: Select all

PROMPT "Please enter subject street address:" !VAR1
PROMPT "Enter subject zip code:" !VAR2
PROMPT "Enter subject city" !VAR7
SET !EXTRACT NULL
ADD !EXTRACT {{!VAR1}}
'*******Create csv file woth address in COL1*************
FILEDELETE NAME=C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv

with !VAR1 in COL1, then accessing csv in y.iim:

Code: Select all

  
'****************open datasouce****************
SET !DATASOURCE C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv
SET !DATASOURCE_LINE 1
'************************
FRAME F={{FRAME_Nb}}
'******Avg SQFT***************
TAG POS=8 TYPE=TD ATTR=CLASS:compareTd EXTRACT=TXT
'******Avg LP***************
TAG POS=9 TYPE=TD ATTR=CLASS:compareTd EXTRACT=TXT
'******Avg LP/sqft***************
TAG POS=11 TYPE=TD ATTR=CLASS:compareTd EXTRACT=TXT
'******Avg SP***************
TAG POS=10 TYPE=TD ATTR=CLASS:compareTd EXTRACT=TXT
'******Avg SP/sqft***************
TAG POS=12 TYPE=TD ATTR=CLASS:compareTd EXTRACT=TXT
'***Sold/Original List price ratio*******
TAG POS=14 TYPE=TD ATTR=CLASS:compareTd EXTRACT=TXT
'***********DOM/ADOM/CDOM*********
TAG POS=1 TYPE=DIV ATTR=CLASS:center EXTRACT=TXT
'Overwrite old data
FILEDELETE NAME=C:\Users\Public\Documents\iMacros\datasources\CMATaxdata\CMA.csv
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Public\Documents\iMacros\datasources\CMATaxdata FILE=CMA.csv
FRAME NAME=top_frame
'New tab opened open Tax data
TAG POS=1 TYPE=DIV ATTR=ID:taxes_sidemenuheader
TAG POS=2 TYPE=A ATTR=TXT:Monsoon
'New tab opened
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:searchQuery [b]CONTENT={{address}}[/b]
But when I run "A_SVS_TAX_DATA.js" it ignores and jumps over x.iim and starts to execute find_number script. It does not throw an error, but it obviously doesn't like the "creating csv file" bits, cause if I take it out, "A_SVS_TAX_DATA.js" file runs as usual although I'm not able to access !VAR1 as I want to.
Any ideas?
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Dynamic Frame Tracking

Post by chivracq » Fri Jun 16, 2017 3:05 am

azbob wrote:Well most of those iimSets were just for testing as I would pass into post loop than prompt for result..so yea not important.

Here is a follow on question. I am now integrating find_number into existing macros by creating .js files that call .iim files. Following the format of iimPlay(x.iim), run find_number .js, passing Frame_Nb to next iimPlay(y.iim).
In this instance imacros file named A_SVS_TAX_DATA.js.
In first x.iim in file I have a prompt for address that I store in !VAR1 that I want to access in y.iim to pass to a web page.
So what I tried to do was create a csv file in x.iim:

Code: Select all

PROMPT "Please enter subject street address:" !VAR1
PROMPT "Enter subject zip code:" !VAR2
PROMPT "Enter subject city" !VAR7
SET !EXTRACT NULL
ADD !EXTRACT {{!VAR1}}
'*******Create csv file woth address in COL1*************
FILEDELETE NAME=C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv

with !VAR1 in COL1, then accessing csv in y.iim:

Code: Select all

  
'****************open datasouce****************
SET !DATASOURCE C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv
SET !DATASOURCE_LINE 1
'************************
FRAME F={{FRAME_Nb}}
'******Avg SQFT***************
TAG POS=8 TYPE=TD ATTR=CLASS:compareTd EXTRACT=TXT
'******Avg LP***************
TAG POS=9 TYPE=TD ATTR=CLASS:compareTd EXTRACT=TXT
'******Avg LP/sqft***************
TAG POS=11 TYPE=TD ATTR=CLASS:compareTd EXTRACT=TXT
'******Avg SP***************
TAG POS=10 TYPE=TD ATTR=CLASS:compareTd EXTRACT=TXT
'******Avg SP/sqft***************
TAG POS=12 TYPE=TD ATTR=CLASS:compareTd EXTRACT=TXT
'***Sold/Original List price ratio*******
TAG POS=14 TYPE=TD ATTR=CLASS:compareTd EXTRACT=TXT
'***********DOM/ADOM/CDOM*********
TAG POS=1 TYPE=DIV ATTR=CLASS:center EXTRACT=TXT
'Overwrite old data
FILEDELETE NAME=C:\Users\Public\Documents\iMacros\datasources\CMATaxdata\CMA.csv
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Public\Documents\iMacros\datasources\CMATaxdata FILE=CMA.csv
FRAME NAME=top_frame
'New tab opened open Tax data
TAG POS=1 TYPE=DIV ATTR=ID:taxes_sidemenuheader
TAG POS=2 TYPE=A ATTR=TXT:Monsoon
'New tab opened
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:searchQuery [b]CONTENT={{address}}[/b]
But when I run "A_SVS_TAX_DATA.js" it ignores and jumps over x.iim and starts to execute find_number script. It does not throw an error, but it obviously doesn't like the "creating csv file" bits, cause if I take it out, "A_SVS_TAX_DATA.js" file runs as usual although I'm not able to access !VAR1 as I want to.
Any ideas?
Oh... yeah...!, looks like a new Challenge. pfff, I thought your Thread was solved...!?, just back from some "heavy" (Musical) Evening now (I'm an Artist/Musician/DJ IRL...), I'll have a look "tomorrow" after some "Sleep", ah-ah...!
Last edited by chivracq on Fri Jun 16, 2017 5:36 pm, edited 1 time in total.
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
azbob
Posts: 85
Joined: Mon Sep 21, 2009 6:16 pm

Re: Dynamic Frame Tracking

Post by azbob » Fri Jun 16, 2017 5:32 am

Okay
Thanks..
azbob
Posts: 85
Joined: Mon Sep 21, 2009 6:16 pm

Re: Dynamic Frame Tracking

Post by azbob » Fri Jun 16, 2017 3:58 pm

BTW: Attempts:
SAVE AS: long shot, but NG threw: wrong format of SAVEAS command, line 28 (Error code: -910)
iimSet("Address",address) in .iim's:but threw:can not parse macro line: iimSet("address",{{!VAR1}}) (Error code: -910)
Maybe I have looked at this too long....
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Dynamic Frame Tracking

Post by chivracq » Fri Jun 16, 2017 5:54 pm

azbob wrote:BTW: Attempts:
SAVE AS: long shot, but NG threw: wrong format of SAVEAS command, line 28 (Error code: -910)
iimSet("Address",address) in .iim's:but threw:can not parse macro line: iimSet("address",{{!VAR1}}) (Error code: -910)
Maybe I have looked at this too long....
I didn't understand "NG"...

- Hum, you may need to escape (=double) the Backslashes for 'FILEDELETE' and 'SAVEAS'.
- You may want to add an '!ERRORIGNORE' around the 'FILEDELETE'... which will fail the next time you want to run this Macro if the File already got deleted (from some previous Run)...
- You are using '!VAR7' for a 'PROMPT' while according to the Wiki, you can only use '!VAR1'-'!VAR3' for an Input 'PROMPT'...
- Check the ReturnCode on 'x.iim' and use 'iimGetErrorText()' to debug that Script...

Code: Select all

iimSet("Address",address) in .iim's:but threw:can not parse macro line: iimSet("address",{{!VAR1}}) (Error code: -910)
=> Yeah, you cannot use '!VAR1', I think, in a '.js' Script, you need to use '!EXTRACT' and 'iimGetExtract()' to pass a Var from an '.iim' to a '.js' Script...
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
azbob
Posts: 85
Joined: Mon Sep 21, 2009 6:16 pm

Re: Dynamic Frame Tracking

Post by azbob » Fri Jun 16, 2017 7:32 pm

NG=no good
Oh interesting about !VAR7...must get by okay as have been using that macro for months with no problems.
Just to be clear here is the code of JS file "A_SVS_TAX_DATA.js":

Code: Select all

//Stewart Valuations SFD JS_IMACRO 6/14/2017

iimPlay('++SFD_Stewart_Valuations_STEP_1.iim');
//declarations
var fnb=(14);

var find_number =  "CODE:";
	find_number += "SET !ERRORIGNORE YES" + "\n";
	find_number += "SET !EXTRACT NULL" + "\n";
	find_number +=  "FRAME F={{Frame_Nb}}" + "\n";
	find_number +=  "SET !TIMEOUT_STEP 0" + "\n";
	find_number +=  "TAG POS=8 TYPE=TD ATTR=CLASS:compareTd EXTRACT=TXT" + "\n";
	

	for(; fnb <= 18; fnb++){
		iimSet("Frame_Nb",fnb);
		iimPlay(find_number);
		var frame_valid = iimGetLastExtract(1);
	

//if extract was frame number than save frame number and play rest of macro
	if (frame_valid !== "#EANF#")
     	{
		iimSet("Frame_Nb",fnb);
		var Frame_Nb=fnb;
		break;
	}
	
	}
iimPlay('++SFD_Stewart_Valuations_STEP_2.iim');
So this code is in "iimPlay('++SFD_Stewart_Valuations_STEP_1.iim')

Code: Select all

PROMPT "Please enter subject street address:" !VAR1
PROMPT "Enter subject zip code:" !VAR2
PROMPT "Enter subject city" !VAR7
SET !EXTRACT NULL
ADD !EXTRACT {{!VAR1}}
'*******Create csv file with address in COL1*************
FILEDELETE NAME=C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv
and then I want to access Address.csv to use contents of !COL1 with this code that is in iimPlay('++SFD_Stewart_Valuations_STEP_2.iim');:

Code: Select all

'****************open datasouce****************
SET !DATASOURCE C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv
SET !DATASOURCE_LINE 1
SET address {{!COL1}}
'>
'>
Set
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:searchQuery [b]CONTENT={{address}}[/b]
azbob
Posts: 85
Joined: Mon Sep 21, 2009 6:16 pm

Re: Dynamic Frame Tracking

Post by azbob » Sun Jun 18, 2017 3:22 am

Okay thanks to your help and correcting a few typos, I got it running.
This code goes in .iim macro 1:

Code: Select all

'
PROMPT "Please enter subject street address:" Sub_address
PROMPT "Enter subject city" Sub_city
PROMPT "Enter subject zip code:" Sub_zip
'
'**********STORE SUBJECT ADDRESS IN CSV FILE SO FOLLOWING MACROS CAN ACCESS**********************
SET !EXTRACT NULL
ADD !EXTRACT {{Sub_address}}
ADD !EXTRACT {{Sub_city}}
ADD !EXTRACT {{Sub_zip}}
'
FILEDELETE NAME=C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Public\Documents\iMacros\datasources\BBformdata FILE=Address.csv
Then this code goes in .iim macro 2

Code: Select all

'****************open datasouce****************
SET !DATASOURCE C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv
SET !DATASOURCE_LINE 1
SET Sub_address {{!COL1}}
SET Sub_city {{!COL2}}
SET Sub_zip {{!COL3}}
'************************
All is well the .js active frame finder .js bit goes at ludicrous speed compared to the other method.
Alas I couldn't have got to this one without the other so all is good.
Thanks again...
BTW: You probably know this, when splitting a larger macro into separate parts interspersed with .js files, the TAB reference flow gets severed.
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Dynamic Frame Tracking

Post by chivracq » Sun Jun 18, 2017 2:51 pm

azbob wrote:NG=no good
Oh interesting about !VAR7...must get by okay as have been using that macro for months with no problems.
Just to be clear here is the code of JS file "A_SVS_TAX_DATA.js":

Code: Select all

//Stewart Valuations SFD JS_IMACRO 6/14/2017

iimPlay('++SFD_Stewart_Valuations_STEP_1.iim');
//declarations
var fnb=(14);

var find_number =  "CODE:";
	find_number += "SET !ERRORIGNORE YES" + "\n";
	find_number += "SET !EXTRACT NULL" + "\n";
	find_number +=  "FRAME F={{Frame_Nb}}" + "\n";
	find_number +=  "SET !TIMEOUT_STEP 0" + "\n";
	find_number +=  "TAG POS=8 TYPE=TD ATTR=CLASS:compareTd EXTRACT=TXT" + "\n";
	

	for(; fnb <= 18; fnb++){
		iimSet("Frame_Nb",fnb);
		iimPlay(find_number);
		var frame_valid = iimGetLastExtract(1);
	

//if extract was frame number than save frame number and play rest of macro
	if (frame_valid !== "#EANF#")
     	{
		iimSet("Frame_Nb",fnb);
		var Frame_Nb=fnb;
		break;
	}
	
	}
iimPlay('++SFD_Stewart_Valuations_STEP_2.iim');
So this code is in "iimPlay('++SFD_Stewart_Valuations_STEP_1.iim')

Code: Select all

PROMPT "Please enter subject street address:" !VAR1
PROMPT "Enter subject zip code:" !VAR2
PROMPT "Enter subject city" !VAR7
SET !EXTRACT NULL
ADD !EXTRACT {{!VAR1}}
'*******Create csv file with address in COL1*************
FILEDELETE NAME=C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv
and then I want to access Address.csv to use contents of !COL1 with this code that is in iimPlay('++SFD_Stewart_Valuations_STEP_2.iim');:

Code: Select all

'****************open datasouce****************
SET !DATASOURCE C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv
SET !DATASOURCE_LINE 1
SET address {{!COL1}}
'>
'>
Set
TAG POS=1 TYPE=INPUT:TEXT ATTR=NAME:searchQuery [b]CONTENT={{address}}[/b]
Ah, OK for "NG"...

OK..., was waiting for you to apply any of my "Suggestions"...
azbob wrote:Okay thanks to your help and correcting a few typos, I got it running.
This code goes in .iim macro 1:

Code: Select all

'
PROMPT "Please enter subject street address:" Sub_address
PROMPT "Enter subject city" Sub_city
PROMPT "Enter subject zip code:" Sub_zip
'
'**********STORE SUBJECT ADDRESS IN CSV FILE SO FOLLOWING MACROS CAN ACCESS**********************
SET !EXTRACT NULL
ADD !EXTRACT {{Sub_address}}
ADD !EXTRACT {{Sub_city}}
ADD !EXTRACT {{Sub_zip}}
'
FILEDELETE NAME=C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv
SAVEAS TYPE=EXTRACT FOLDER=C:\Users\Public\Documents\iMacros\datasources\BBformdata FILE=Address.csv
Then this code goes in .iim macro 2

Code: Select all

'****************open datasouce****************
SET !DATASOURCE C:\Users\Public\Documents\iMacros\datasources\BBformdata\Address.csv
SET !DATASOURCE_LINE 1
SET Sub_address {{!COL1}}
SET Sub_city {{!COL2}}
SET Sub_zip {{!COL3}}
'************************
All is well the .js active frame finder .js bit goes at ludicrous speed compared to the other method.
Alas I couldn't have got to this one without the other so all is good.
Thanks again...
BTW: You probably know this, when splitting a larger macro into separate parts interspersed with .js files, the TAB reference flow gets severed.
OK, good-good...!

Oh...!, "Lesson" for me, ah-ah...!, apart from '!VAR7' for an Input 'PROMPT' in one of my previous Replies, you can even use 'User-defined' Vars...!?, OK, didn't know that... Well, I never needed more than 1 Var for the very few (Confirmation) Input 'PROMPT's that I use in my own Macros, so I always used '!VAR1' without "experimenting" that much with 'PROMPT', hum..., except in this Thread, ah-ah...!
And I try to avoid (Input) 'PROMPT's in my own Macros, I usually always go for "Full" Automation without any User Interaction, if User Input is "needed", my Scripts are normally more "clever" than me, ah-ah...!, and I think it's always possible to model/compute/generate that Input from the Script itself... I only use 'PROMPT' for Debug Purpose actually...

Hum..., Double Backslashes are not needed then for Paths, I see from your Scripts...

Well, about iMacros losing track of the Tab Sequence, I didn't "really" know because I don't use any '.js' Scripts, but..., tja..., I'm not surprised, it's the same with '.iim' Macros (I have some '.iim's calling another '.iim' in chain), a Script needs a "TAB T=1" at its beginning to know from which Tab it is starting if the Tab Sequence is "important" for the Workflow of your (overall) Script...

Mini-Caveat I foresee in your whole Workflow is the 'FILEDELETE', I mentioned earlier using '!ERRORIGNORE' for it but you didn't follow my Sugg, and I'm not even sure that "would be enough" as your 'iim' Macro will run from the '.js' Script and won't abort if "anything" goes wrong, but the 'FILEDELETE' might fail if for example you have the '.CSV' opened in Excel, then I'm not completely sure about what will happen with the 'SAVEAS', if it will fail as well or if the Data will get appended to the existing File that could not get deleted or if a new File will be created with "(1)" in its Name, but in both cases, your next Macro will reuse the previous Data from Row_1 from your existing File... Oops...! :(
=> You might want to separate that part from its current Macro and check for the RetCode on some mini-Macro doing only the 'FILEDELETE' (and it's possible to add some extra check by "misusing" the '!FOLDER_DATASOURCE' Command which is able to find out if a specific Folder or File does exist (or doesn't exist anymore after the Delete, ah-ah..!))...

Another Method that I use is to include a Timestamp in your 'SAVEAS' and have your 2nd Macro check this Timestamp to decide that if the Data is "older" than 5 min for example, then stg went "wrong" in the whole Process... :idea:
I use 'STOPWATCH' as well to check if a Macro completed in some "reasonable" amount of time, to eventually decide if it needs to run again, but that might be a bit of a hassle in your case as you'll need to have the 3 Macros to "communicate" with each other..., the 'Timestamp' Method will probably be easier... Oh yeah...!, I guess this will be your next "Challenge", ah-ah...! :shock:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Eza168
Posts: 1
Joined: Tue Oct 18, 2022 4:39 am

Re: Dynamic Frame Tracking

Post by Eza168 » Sun Dec 11, 2022 5:34 pm

chivracq wrote:
Sun May 28, 2017 11:22 am
If your Frame_Nb varies within [14,18] => 5 Values, "my" Solution would be to 5 times "try" to extract one (or more) of the Fields you want to extract to check if it is present in that Frame_Nb to therefore "deduct" which Frame_Nb to use using 'EVAL()' + 'CASE' or 'if else' for example, stg like:

Code: Select all

'Check FRAME_Nb for F[14,18]:
FRAME F=14
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_14 {{!EXTRACT}}
'>
FRAME F=15
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_15 {{!EXTRACT}}
'>
FRAME F=16
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_16 {{!EXTRACT}}
'>
FRAME F=17
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_17 {{!EXTRACT}}
'>
FRAME F=18
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_18 {{!EXTRACT}}

'Deduct FRAME_Nb:
SET FRAME_Nb EVAL("var f14='{{F_14}}', f15='{{F_15}}', f16='{{F_16}}', f17='{F_17}}', f18='{{F_18}}'; var nf='#EANF#'; var z; if(f14!=nf){z=14;} else if(f15!=nf){z=15;} else if(f16!=nf){z=16;} else if(f17!=nf){z=17;} else if(f18!=nf){z=18;} else{z='ERROR...!';}; z;")
PROMPT FRAME_Nb:<SP>_{{FRAME_Nb}}_
PAUSE

FRAME F={{FRAME_Nb}}
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
TAG POS=1 TYPE=TD ATTR=ID:ctLP EXTRACT=TXT
TAG POS=1 TYPE=TD ATTR=ID:lowSP EXTRACT=TXT
TAG POS=1 TYPE=TD ATTR=ID:hiSP EXTRACT=TXT
TAG POS=1 TYPE=SPAN ATTR=ID:ctSP EXTRACT=TXT
TAG POS=1 TYPE=TD ATTR=ID:avgDom EXTRACT=TXT
Not tested as your Site is behind Login&Password but I guess you can understand the "Principle"...

The 5x 'if else' Construction is maybe not very "elegant", there are probably more elegant Solutions, ah-ah...!, but this one should work... :oops:
Excuse me to asking when i adapt your code to my need, since i face similar problem but seems not worked for my side. For your information, im using imacros version 8970419 with palemoon browser 28.10.0 (64bit) windows 10nt.

I only adapt a little since my frame number change from 6 - 10 in https://openlearning.com for scripting about me page text area.

here is my small editing from your code, but all will result FRAME=6 , even when i deleted all things for f6

Code: Select all

'Check FRAME_Nb for F[6,10]:
FRAME F=6
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_6 {{!EXTRACT}}
'>
FRAME F=7
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_7 {{!EXTRACT}}
'>
FRAME F=8
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_8 {{!EXTRACT}}
'>
FRAME F=9
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_9 {{!EXTRACT}}
'>
FRAME F=10
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_10 {{!EXTRACT}}

'Deduct FRAME_Nb:
SET FRAME_Nb EVAL("var f6='{{F_6}}', f7='{{F_7}}', f8='{{F_8}}', f9='{F_9}}', f10='{{F_10}}'; var nf='#EANF#'; var z; if(f6!=nf){z=6;} else if(f7!=nf){z=7;} else if(f8!=nf){z=8;} else if(f9!=nf){z=9;} else if(f10!=nf){z=10;} else{z='ERROR...!';}; z;")
PROMPT FRAME_Nb:<SP>_{{FRAME_Nb}}_
PAUSE

FRAME F={{FRAME_Nb}}
SET !EXTRACT NULL
EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
WAIT SECONDS=1
EVENTS TYPE=KEYPRESS SELECTOR="HTML>BODY" CHARS="Sample text writing to test frame"
Did i copy your code any missed? or maybe something about anything else. Thanks very much for your time to take a look and give me your generousity.

Regards,
Albert
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Dynamic Frame Tracking

Post by chivracq » Wed Dec 14, 2022 3:10 pm

Full Quote:
Eza168 wrote:
Sun Dec 11, 2022 5:34 pm
chivracq wrote:
Sun May 28, 2017 11:22 am
If your Frame_Nb varies within [14,18] => 5 Values, "my" Solution would be to 5 times "try" to extract one (or more) of the Fields you want to extract to check if it is present in that Frame_Nb to therefore "deduct" which Frame_Nb to use using 'EVAL()' + 'CASE' or 'if else' for example, stg like:

Code: Select all

'Check FRAME_Nb for F[14,18]:
FRAME F=14
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_14 {{!EXTRACT}}
'>
FRAME F=15
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_15 {{!EXTRACT}}
'>
FRAME F=16
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_16 {{!EXTRACT}}
'>
FRAME F=17
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_17 {{!EXTRACT}}
'>
FRAME F=18
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_18 {{!EXTRACT}}

'Deduct FRAME_Nb:
SET FRAME_Nb EVAL("var f14='{{F_14}}', f15='{{F_15}}', f16='{{F_16}}', f17='{F_17}}', f18='{{F_18}}'; var nf='#EANF#'; var z; if(f14!=nf){z=14;} else if(f15!=nf){z=15;} else if(f16!=nf){z=16;} else if(f17!=nf){z=17;} else if(f18!=nf){z=18;} else{z='ERROR...!';}; z;")
PROMPT FRAME_Nb:<SP>_{{FRAME_Nb}}_
PAUSE

FRAME F={{FRAME_Nb}}
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
TAG POS=1 TYPE=TD ATTR=ID:ctLP EXTRACT=TXT
TAG POS=1 TYPE=TD ATTR=ID:lowSP EXTRACT=TXT
TAG POS=1 TYPE=TD ATTR=ID:hiSP EXTRACT=TXT
TAG POS=1 TYPE=SPAN ATTR=ID:ctSP EXTRACT=TXT
TAG POS=1 TYPE=TD ATTR=ID:avgDom EXTRACT=TXT
Not tested as your Site is behind Login&Password but I guess you can understand the "Principle"...

The 5x 'if else' Construction is maybe not very "elegant", there are probably more elegant Solutions, ah-ah...!, but this one should work... :oops:
Excuse me to asking when i adapt your code to my need, since i face similar problem but seems not worked for my side. For your information, im using

Code: Select all

imacros version 8970419 with palemoon browser 28.10.0 (64bit) windows 10nt.
I only adapt a little since my frame number change from 6 - 10 in https://openlearning.com for scripting about me page text area.

here is my small editing from your code, but all will result FRAME=6 , even when i deleted all things for f6

Code: Select all

'Check FRAME_Nb for F[6,10]:
FRAME F=6
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_6 {{!EXTRACT}}
'>
FRAME F=7
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_7 {{!EXTRACT}}
'>
FRAME F=8
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_8 {{!EXTRACT}}
'>
FRAME F=9
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_9 {{!EXTRACT}}
'>
FRAME F=10
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_10 {{!EXTRACT}}

'Deduct FRAME_Nb:
SET FRAME_Nb EVAL("var f6='{{F_6}}', f7='{{F_7}}', f8='{{F_8}}', f9='{F_9}}', f10='{{F_10}}'; var nf='#EANF#'; var z; if(f6!=nf){z=6;} else if(f7!=nf){z=7;} else if(f8!=nf){z=8;} else if(f9!=nf){z=9;} else if(f10!=nf){z=10;} else{z='ERROR...!';}; z;")
PROMPT FRAME_Nb:<SP>_{{FRAME_Nb}}_
PAUSE

FRAME F={{FRAME_Nb}}
SET !EXTRACT NULL
EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
WAIT SECONDS=1
EVENTS TYPE=KEYPRESS SELECTOR="HTML>BODY" CHARS="Sample text writing to test frame"
Did i copy your code any missed? or maybe something about anything else. Thanks very much for your time to take a look and give me your generousity.

Regards,
Albert

Euh...!?, a bit surprised you managed to post a 1st Post "freely" without me (Mod on this Forum) having to approve it. while you joined recently (=> 2022-10-18) and only have this current Post in your History, ... but OK, I see you deleted some previous Post of yours, and the whole Thread with it:
"Eza168 02/11/2022 - 13:17 Deleted topic “Imacros to Trick TAG POS which always change randomly.” written by “Eza168” for the following reason » "

And I had apparently not reacted to that Thread, the Quality was probably "too low", or I was "busy" at that time with "real Life", I don't really remember... (Oh yes!, I was indeed "busy" at that time (around 18 of Octb) and for nearly 1 week...) But hum, be "careful", I don't "like it too much" when Users delete or mutilate their Post(s)/Thread(s) instead of improving the Quality and sharing their Solution, and I usually then don't help them (anymore)..., just like you were probably "Happy" to find this current Thread, with a "useful" Script/Solution in it... :idea:

But OK, the Quality of your Post in this current Thread is very correct, and you did "your Research" very well, then hum..., OK... :|

>>>

Alright, your Post is "self-contained", all (needed) Info is in it, I don't need to completely re-dig into the Thread and re-read it from the beginning, which is very good, well for me and for other Users :D , and..., yep-yep, I understand your Scenario and what you are trying to do, ... and what is "going wrong"...

The Script/Implementation visible in the Quote is based on the 'EXTRACT' Mechanism:

Code: Select all

FRAME F=18
SET !EXTRACT NULL
TAG POS=1 TYPE=TD ATTR=ID:hiLP EXTRACT=TXT
SET F_18 {{!EXTRACT}}
=> Then if "F=18" was "correct", the 'F_18' Var would contain some "Extracted Text for the Page/Frame", and if the Fame Number was not correct, 'F_18' would contain the String "#EANF#" as the Element would have not been found and the 'EXTRACT' would return "#EANF#".

But the 'EXTRACT' Mechanism/Command is only supported by the `TAG` Mode, while you are using the `EVENT` Mode yourself in your Script, with:

Code: Select all

'Check FRAME_Nb for F[6,10]:
FRAME F=6
SET !EXTRACT NULL
'EVENT TYPE=CLICK SELECTOR="HTML>BODY" BUTTON=0
SET F_6 {{!EXTRACT}}
The "EVENT ..." Line doesn't really matter, commented out or not, as it not doing anything, what that Part is doing is actually:

Code: Select all

SET !EXTRACT  NULL
SET !VAR1 {{!EXTRACT}}
PROMPT VAR1:<P>_{{!VAR1}}_
... And the PROMPT returns: "VAR1: __", => an empty String, between the 2 Underscores.

=> All your 'F_6', 'F_7', etc Vars all contain the same empty String, ... which is not what you want...! :P

Then later in the Script in the `EVAL` Statement to deduct the Frame Nb:

Code: Select all

'Deduct FRAME_Nb:
SET FRAME_Nb EVAL("var f6='{{F_6}}', f7='{{F_7}}', f8='{{F_8}}', f9='{F_9}}', f10='{{F_10}}'; var nf='#EANF#'; var z; if(f6!=nf){z=6;} else if(f7!=nf){z=7;} else if(f8!=nf){z=8;} else if(f9!=nf){z=9;} else if(f10!=nf){z=10;} else{z='ERROR...!';}; z;")
PROMPT FRAME_Nb:<SP>_{{FRAME_Nb}}_
... the 1st Condition (if(f6!=nf){z=6;}) (=> if(f6!='#EANF#'){z=6;}) will always be True as an empty String ("") is different from the "#EANF#" String, and the `EVAL()` will always return "6". :P

=> You need to first tag and extract some Element that will be on that Frame, but using the `TAG` Mode first, and not the `EVENT` Mode, because you cannot extract using the `EVENT` Mode... Only the `TAG` Mode will be able to populate your 'F_6'...'F_10' Vars, not the `EVENT` Mode... :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
chivracq
Posts: 10301
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Dynamic Frame Tracking

Post by chivracq » Sat Dec 17, 2022 8:42 am

And...?, any Follow-up @Eza168, ... 3 days later...?! :shock:

I already mentioned I was "being nice" in my previous Post, by answering your Qt, while I usually don't help (anymore) Users who delete/mutilate their Posts/Threads instead of sharing their Solution/Script for the Community, ... but not following up on their Threads is also a Show-Killer for me to not help them anymore in the future... (And I always check how a User handled/finished their previous Thread(s)...) :idea:
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE'/'Trial').
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Post Reply