dc09
dc09

Reputation: 486

Loop Within Loop in iMacro

I have the following code in a js file:

i = 0

do
{
    i = i + 1;

    // Set Date +4
    var someDate = new Date();
    var numberOfDaysToAdd = 4;
    someDate.setDate(someDate.getDate() + numberOfDaysToAdd); 

    var dd = someDate.getDate();
    var mm = someDate.getMonth();
    var y = someDate.getFullYear();

    var monthNames = ["January", "February", "March", "April", "May", "June",
                      "July", "August", "September", "October", "November", "December" ];

    ret = iimSet("someFormattedDate",someFormattedDate = monthNames[mm] + ' '+ dd + ','+ y);

    // Opens Order Page Loop
    ret = iimSet("myloop", i);
    ret = iimPlay("sfiles/#Loop_Extract_1.iim");

    // Extract and set order status
    var status = iimGetLastExtract();
 
    // Continue if order status processing
    if (status.toLowerCase().indexOf('processing') >= 0)
    {
        ret = iimSet("someFormattedDate",someFormattedDate = monthNames[mm] + ' '+ dd + ','+ y);
        ret = iimPlay ("sfiles/#Loop_1.iim");
    }
}
while (ret  > 0);

This plays Loop_Extract_1.iim on loop, the contents of which are a follows:

VERSION BUILD=9030808 RECORDER=FX
TAB T=1
'Set Data source excel sheet
SET !DATASOURCE C:\Users\pc\Desktop\Script_Excel\orders.csv
SET !DATASOURCE_COLUMNS 1
SET !DATASOURCE_LINE {{myloop}}
URL GOTO=https://www.example.com/post.php?post={{!COL1}}&action=edit

Then, it play Loop1.iim, the contents of which are as follows:

VERSION BUILD=9030808 RECORDER=FX

TAB T=1

'Click on Load in Order Viewer Button
SET !EXTRACT_TEST_POPUP NO
SET !EXTRACT NULL 
TAG POS=1 TYPE=SPAN ATTR=CLASS:layers

I need to define another loop inside Loop_1.iim, such that the POS is defined by the number written in column 2 of the datasource sheet. For example - if column 2 has 3, Loop_1.iim should play with POS=1, then it should play with POS=2 and so on till it reaches 3. How to do this?

Upvotes: 0

Views: 83

Answers (0)

Related Questions