How to loop macros with Javascript?

hillz

Registered Member
Joined
Aug 14, 2011
Messages
55
Reaction score
3
I'm sorry for not being clear last time mate, can you run this code in your computer?

1. Datasource.iim
Code:
VERSION BUILD=8240212 RECORDER=FX
TAB T=1
'SET !REPLAYSPEED SLOW
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
SET !DATASOURCE test.csv
SET !DATASOURCE_COLUMNS 4
SET !DATASOURCE_LINE {{!LOOP}} 
SET !LOOP {{myLoop}}
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT 60


URL GOTO=galihpa.tk
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=NAME:usrname CONTENT={{!COL1}}
TAG POS=2 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=NAME:usrname CONTENT={{!COL2}}
TAG POS=3 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=NAME:usrname CONTENT={{!COL3}}


TAG POS=1 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=VALUE:* EXTRACT=TXT
TAG POS=2 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=VALUE:* EXTRACT=TXT
TAG POS=3 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=VALUE:* EXTRACT=TXT

2. Job.iim
Code:
URL GOTO=galihpa.tk/test
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=NAME:usrname CONTENT={{myData1}}
TAG POS=2 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=NAME:usrname CONTENT={{myData2}}
TAG POS=3 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=NAME:usrname CONTENT={{myData3}}
WAIT SECONDS=5

3. test.js
Code:
var i;
var data1;
var data2;
var data3;
var data4;
var data5;
var data6;
var data7;


for (i = 1; i < 5; i++)
    {
        function myFunction()
            {
                iimSet ("myLoop",i);
                iimPlay ("Datasource.iim");
                
                data1 = iimGetLastExtract(1);
                data2 = iimGetLastExtract(2);
                data3 = iimGetLastExtract(3);
                
                iimSet ("myData1", data1);
                iimSet ("myData2", data2);
                iimSet ("myData3", data3);
                
                iimPlay ("Job.iim");
            }
        myFunction()
    }

And here's the test.csv file

Please run that test.js file, you'll notice that on the first-last loop, the extracted data is always like this:
  1. address1
  2. zip1
  3. city1

What I want is like this:
First loop:
  1. address1
  2. zip1
  3. city1

Second loop:
  1. address2
  2. zip2
  3. city2

Third Loop:
  1. address3
  2. zip3
  3. city3

I hope this is easier to understand. Please tell me where I went wrong with that script.
Thanks.
 
Last edited:
I can help you but I need to see the entire code.
Basically you need to create a javascript loop and use iimset to set variables that will be used instead of the imacros loop.
 
oops repost sorry
 

Attachments

  • 1743550_10201323050830826_2014599729_n.jpg
    1743550_10201323050830826_2014599729_n.jpg
    20.8 KB · Views: 378
Last edited:
In your first post, you wrote that the first one (PasteData.iim) should paste "Sam/..." and the second one should paste the country then in your other post you linked two identical codes. If they both do the same thing they can be merged in one.
And also you said you have 200 "Data", what is that supposed to mean? 200 of which one? each one of them? or both of them?
Anyway, with the info you provided this is as far as I can help you:
Code:
for (var account=1; account<=74; account++)
{
iimSet ("account", account); // Use this variable in login.iim to loop through the accounts
iimPlay ("LoginA.iim");
/* Add a loop (Or 2 loops, it depends on what you're trying to accomplish I can't really tell) for these two functions that will loop through the data from, use iimSet in the same way i did */
      iimPlay ("PasteData.iim");
      iimPlay ("AnotherPasteData.iim");
}
 
SOLVED

Damn, I should have noticed. I made a simple mistake.
In Datasource.iim I have the following:

Code:
SET !DATASOURCE_LINE {{!LOOP}} 
SET !LOOP {{myLoop}}

I should first SET the !LOOP then SET the !DATASOURCE. So the entire code will be like this:

Code:
VERSION BUILD=8240212 RECORDER=FX
TAB T=1
'SET !REPLAYSPEED SLOW
SET !ERRORIGNORE YES
SET !TIMEOUT_STEP 0
SET !DATASOURCE test.csv
SET !DATASOURCE_COLUMNS 4
SET !LOOP {{myLoop}}
SET !DATASOURCE_LINE {{!LOOP}} 
SET !EXTRACT_TEST_POPUP NO
SET !TIMEOUT 60




URL GOTO=galihpa.tk
TAG POS=1 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=NAME:usrname CONTENT={{!COL1}}
TAG POS=2 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=NAME:usrname CONTENT={{!COL2}}
TAG POS=3 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=NAME:usrname CONTENT={{!COL3}}




TAG POS=1 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=VALUE:* EXTRACT=TXT
TAG POS=2 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=VALUE:* EXTRACT=TXT
TAG POS=3 TYPE=INPUT:TEXT FORM=ID:usrform ATTR=VALUE:* EXTRACT=TXT

Thanks to Mr.Profit for his assistance through PM. I really appreciate his help :D
 
Back
Top