How to use !Col function but with a variable ?
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
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
How to use !Col function but with a variable ?
Using iMacros for FF (8.9.7) in FF (46.0.1) , Win 7 x64
and also iMacros 10 (Separately from above)
I am trying to accomplish this : (Described Below)
Suppose i have a text file .
TestDataSource.txt
http://a.com
http://b.com
http://c.com
http://d.com
http://e.com
http://f.com
I am going to the website
http://ascii.cl/url-decoding.htm
Using
URL GOTO=http://ascii.cl/url-decoding.htm
And
SET !VAR1 1
I want to use
TAG POS=1 TYPE=TEXTAREA FORM=NAME:urlform ATTR=NAME:textarea CONTENT={{!COL1}}<BR>
But Like this
{{!COL{!VAR1}}}
ADD !VAR1 1
{{!COL{!VAR1}}}
In this way it should continue as long as the increment occurs
So that it prints
{{!COL1}}
then
{{!COL2}}
then
{{!COL3}}
and so on
Ultimate goal is to create a condition based loop like thing.
How do i achieve this ?
{{!COL{!VAR1}}}
and also iMacros 10 (Separately from above)
I am trying to accomplish this : (Described Below)
Suppose i have a text file .
TestDataSource.txt
http://a.com
http://b.com
http://c.com
http://d.com
http://e.com
http://f.com
I am going to the website
http://ascii.cl/url-decoding.htm
Using
URL GOTO=http://ascii.cl/url-decoding.htm
And
SET !VAR1 1
I want to use
TAG POS=1 TYPE=TEXTAREA FORM=NAME:urlform ATTR=NAME:textarea CONTENT={{!COL1}}<BR>
But Like this
{{!COL{!VAR1}}}
ADD !VAR1 1
{{!COL{!VAR1}}}
In this way it should continue as long as the increment occurs
So that it prints
{{!COL1}}
then
{{!COL2}}
then
{{!COL3}}
and so on
Ultimate goal is to create a condition based loop like thing.
How do i achieve this ?
{{!COL{!VAR1}}}
Last edited by Reaper on Mon Jun 06, 2016 10:21 am, edited 1 time in total.
Re: How to use !Col function but with a variable ?
So until Now i
came up with this
SET !DATASOURCE E:\Internet<SP>Projects<SP>v2\File<SP>Upload<SP>-<SP>iMacros<SP>-<SP>Resources\DataSource<SP>Test.txt
URL GOTO=http://ascii.cl/url-decoding.htm
TAG POS=1 TYPE=TEXTAREA FORM=NAME:urlform ATTR=NAME:textarea CONTENT={{!COL1}}<BR>{{!COL2}}<BR>{{!COL3}}
So you see there i wrote only upto !col3
But since the number of links in my text file can vary (like from 5 to 50)
I want to implement a way to calculate the number of lines or links
and set it as a reverse counting variable n
and use something like
!col n
!col n-1
.
.
.
!col 1
I want it to print
http://a.com
http://b.com
http://c.com
http://d.com
http://e.com
http://f.com
What / Which part should be modified & How ?
came up with this
SET !DATASOURCE E:\Internet<SP>Projects<SP>v2\File<SP>Upload<SP>-<SP>iMacros<SP>-<SP>Resources\DataSource<SP>Test.txt
URL GOTO=http://ascii.cl/url-decoding.htm
TAG POS=1 TYPE=TEXTAREA FORM=NAME:urlform ATTR=NAME:textarea CONTENT={{!COL1}}<BR>{{!COL2}}<BR>{{!COL3}}
So you see there i wrote only upto !col3
But since the number of links in my text file can vary (like from 5 to 50)
I want to implement a way to calculate the number of lines or links
and set it as a reverse counting variable n
and use something like
!col n
!col n-1
.
.
.
!col 1
I want it to print
http://a.com
http://b.com
http://c.com
http://d.com
http://e.com
http://f.com
What / Which part should be modified & How ?
Re: How to use !Col function but with a variable ?
Reaper wrote:Using iMacros for FF (8.9.7) in FF (46.0.1) , Win 7 x64
and also iMacros 10 (Separately from above)
I am trying to accomplish this : (Described Below)
Suppose i have a text file .
TestDataSource.txtI am going to the websiteCode: Select all
http://a.com http://b.com http://c.com http://d.com http://e.com http://f.com
http://ascii.cl/url-decoding.htm
UsingAndCode: Select all
URL GOTO=http://ascii.cl/url-decoding.htm
I want to useCode: Select all
SET !VAR1 1
But Like thisCode: Select all
TAG POS=1 TYPE=TEXTAREA FORM=NAME:urlform ATTR=NAME:textarea CONTENT={{!COL1}}<BR>
In this way it should continue as long as the increment occursCode: Select all
{{!COL{!VAR1}}} ADD !VAR1 1 {{!COL{!VAR1}}}
So that it prints
{{!COL1}}
then
{{!COL2}}
then
{{!COL3}}
and so on
Ultimate goal is to create a condition based loop like thing.
How do i achieve this ?
{{!COL{!VAR1}}}
Hum, the '{{!COL{{!VAR1}}}}' Construction doesn't work, I've already filled some EnhReq to implement it in this Thread for example:Reaper wrote:So until Now i came up with this
So you see there i wrote only upto !col3Code: Select all
SET !DATASOURCE E:\Internet<SP>Projects<SP>v2\File<SP>Upload<SP>-<SP>iMacros<SP>-<SP>Resources\DataSource<SP>Test.txt URL GOTO=http://ascii.cl/url-decoding.htm TAG POS=1 TYPE=TEXTAREA FORM=NAME:urlform ATTR=NAME:textarea CONTENT={{!COL1}}<BR>{{!COL2}}<BR>{{!COL3}}
But since the number of links in my text file can vary (like from 5 to 50)
I want to implement a way to calculate the number of lines or links
and set it as a reverse counting variable n
and use something likeI want it to printCode: Select all
!col n !col n-1 . . . !col 1
What / Which part should be modified & How ?Code: Select all
http://a.com http://b.com http://c.com http://d.com http://e.com http://f.com
There is a Workaround in '.js' where you can concatenate the String in JavaScript. You have a few Threads on the Forum about that.chivracq wrote:- Implement a "Super" Built-in Var that could contain Commands like 'OPEN' / 'CLOSE' / 'REFRESH' / 'CLEAR' / etc and other (Built-in) Vars like for example in '{{!COL{{!LOOP}}}}'.
But from looking at the Structure of your '.CSV' DataSource, it looks to me that your '.CSV' is "Vertical" with only one Column, simply using '{{!COL1}}' and looping your Macro with '{{!LOOP}}' will let you access the Data from all the Rows..., and it looks to me that it's '!DATASOURCE_LINE' you need to increment instead of '!COLn'.
From there you have several Options...
Either in pure '.iim', you can fetch your Data Row by Row from the DataSource and input it for each Loop in your 'TEXTAREA' Field if the Field lets you append new Data into it or you may have to re-extract it at each Loop to be able to append the new Row, but extracting from some 'INPUT'/'TEXTAREA' Field using the Standard 'TAG' doesn't always work, you might need to use (a Combination with) the 'EVENT' Mode.
Or you can use a (Main) '.js' Script which will drive a first '.iim' Macro looping through the DataSource to fetch the Data Row by Row that the '.js' Script will aggregate before reusing it in some second '.iim' Macro for the Input part into the 'TEXTAREA' Field.
But the Looping part for 50 Rows could take some time, 5-10 sec at least or even up to 30 sec, I would think, for 50 Rows.
There is a simple Trick that allows you to fetch all the 50 Rows with just one single Statement, by manually adding a Double Quote at the complete Beginning and the complete End of your '.CSV' using Notepad, and iMacros will see all the Content between the 2 Double Quotes as one Cell, at least on FF. And I would think that that would handle as well automatically all the '<BR>' Tags..
Another Trick to fetch the Content of the 50 Rows with just one Statement is to save your DataSource as a '.TXT' or '.HTML' File (and not '.CSV') and to open it in your Browser from iMacros in a second TAB to extract all its Content at the 'TABLE' or 'BODY' Level.
- (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...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: How to use !Col function but with a variable ?
You need to do something like:
DivHtml = "<div>....</div>';
MyArray = new Array();
Outcomes = new Array();
Outcomes[0] = 'test1';
Outcomes[1] = 'test2';
Outcomes[2] = 'test3';
Increment = -1;
for (loop = 0; loop < Outcomes.length; loop++) {
if (DivHtml.toLowerCase().indexOf(Outcomes[loop]) != -1) {
Increment = Increment + 1;
if (Increment > 0) {
MyArray[Increment] = '&&value' + loop + ":" + Outcomes[loop];
} else {
MyArray[Increment] = Outcomes[loop];
}
}
}
You need to get Html of the Div and loop through all possible fields that you think may occur, the final array "MyArry" will hold the complete instruction like: value1:__value__&&value2:__value__...
DivHtml = "<div>....</div>';
MyArray = new Array();
Outcomes = new Array();
Outcomes[0] = 'test1';
Outcomes[1] = 'test2';
Outcomes[2] = 'test3';
Increment = -1;
for (loop = 0; loop < Outcomes.length; loop++) {
if (DivHtml.toLowerCase().indexOf(Outcomes[loop]) != -1) {
Increment = Increment + 1;
if (Increment > 0) {
MyArray[Increment] = '&&value' + loop + ":" + Outcomes[loop];
} else {
MyArray[Increment] = Outcomes[loop];
}
}
}
You need to get Html of the Div and loop through all possible fields that you think may occur, the final array "MyArry" will hold the complete instruction like: value1:__value__&&value2:__value__...
Hire the BoT-fReeak!
botspecialist.blogspot.com
botspecialist.blogspot.com
Re: How to use !Col function but with a variable ?
Yep, but that will still take 5-10-30 sec..., I gave a few Solutions for 0.5 sec instead... (in pure '.iim', ah-ah...! sorry private Joke...!)janib4all wrote:You need to do something like:You need to get Html of the Div and loop through all possible fields that you think may occur, the final array "MyArry" will hold the complete instruction like: value1:__value__&&value2:__value__...Code: Select all
DivHtml = "<div>....</div>'; MyArray = new Array(); Outcomes = new Array(); Outcomes[0] = 'test1'; Outcomes[1] = 'test2'; Outcomes[2] = 'test3'; Increment = -1; for (loop = 0; loop < Outcomes.length; loop++) { if (DivHtml.toLowerCase().indexOf(Outcomes[loop]) != -1) { Increment = Increment + 1; if (Increment > 0) { MyArray[Increment] = '&&value' + loop + ":" + Outcomes[loop]; } else { MyArray[Increment] = Outcomes[loop]; } } }
- (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...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...
Re: How to use !Col function but with a variable ?
Code: Select all
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; var row=\"{{tri}}\"-1;var cloumn=\"{{tdj}}\";if(s==\"{{!COL\"+\"{{tri}}\"+\"}}\") s; else MacroError(row+\"科目编码数据不一致\")")
Re: How to use !Col function but with a variable ?
Yep, your Method is good to concatenate the "{{!COLn}}" String but iMacros stops there and doesn't try to go and fetch the Value of the Var.jjj0817 wrote:You can use EVAL to append string ti achive "!COL{{N}}",like my code' s==\"{{!COL\"+\"{{tri}}\"+\"}}\" ',it's look like SQL injectCode: Select all
SET !VAR2 EVAL("var s=\"{{!EXTRACT}}\"; var row=\"{{tri}}\"-1;var cloumn=\"{{tdj}}\";if(s==\"{{!COL\"+\"{{tri}}\"+\"}}\") s; else MacroError(row+\"科目编码数据不一致\")")
This is actually a Workaround/Equivalent used to get the same like the '#NOVAR#' Command.
This simple Macro will demonstrate it: (Just loop it 3 or more times...)
Code: Select all
SET !VAR1 "VAR1 Blabla...!"
SET !VAR2 "VAR2 Bloblo...!"
SET !VAR3 "VAR3 Blublu...!"
SET Var_N EVAL("var r='{{!LOOP}}'; var x='{{!VAR' + r + '}}'; x;")
PROMPT Var_N:<SP>_{{Var_N}}_
- (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...
- FCI not mentioned: I don't even read the Qt...! (or only to catch Spam!)
- Script & URL help a lot for more "educated" Help...