iMacros concatenating strings from datasource

2019-08-14 02:57发布

问题:

In the below iMacros how can I set a variable value and then concatenate it?

    VERSION BUILD=8530828 RECORDER=FX
    TAB T=1
    SET !ERRORIGNORE YES
    SET !DATASOURCE allsource.CSV
    SET !TIMEOUT 1
    SET !VAR! = My<SP>Content<SP>Here.
    TAG POS=1 TYPE=TEXTAREA FORM=ID:pst-main ATTR=ID:description CONTENT={{!COL1}}

How can the SET !VAR1 = MyContentHere. work? Please correct my syntax.

And, how can I concatenate COL1 and VAR1 the below way didn't work

TAG POS=1 TYPE=TEXTAREA FORM=ID:pst-main ATTR=ID:description CONTENT={{!COL1}} !VAR1

Please correct my syntax, thanks

EDIT1

Also, I am able to set Loop start as SET !LOOP 2 how can I set LOOP end without manually setting Loop Number and hit play loop button?

回答1:

To assign a value to a variable, use this:

SET !VAR1 My<SP>Content

Concatenate COL1 and VAR1:

TAG POS=1 TYPE=TEXTAREA FORM=ID:pst-main ATTR=ID:description CONTENT={{!COL1}}{{!VAR1}}

If you don't want to set loop end manually, you'll need to use JavaScripting.

Your macro should look like this:

VERSION BUILD=8530828 RECORDER=FX
TAB T=1
SET !ERRORIGNORE YES
SET !DATASOURCE allsource.CSV
SET !TIMEOUT 1
SET !VAR1 My<SP>Content<SP>Here.
TAG POS=1 TYPE=TEXTAREA FORM=ID:pst-main ATTR=ID:description CONTENT={{!COL1}}{{!VAR1}}

Read here about JavaScripting, you will have to save this code in a *.js file.

var macro = "CODE:SET !ERRORIGNORE YES\n";
macro =+ "SET !DATASOURCE allsource.CSV\n";
macro =+ "SET !DATASOURCE_LINE {{loop}}\n";
macro =+ "SET !TIMEOUT 1\n";
macro =+ "SET !VAR1 My<SP>Content<SP>Here.\n";
macro =+ "TAG POS=1 TYPE=TEXTAREA FORM=ID:pst-main ATTR=ID:description CONTENT={{!COL1}}{{!VAR1}}\n";

for(var i=1;i<=20;i++)
{
iimDisplay(i);
iimSet("loop", i);
iimPlay(macro);
}