Multiple Loops in iMacros for Chrome

Discussions and Tech Support specific to the iMacros for Chrome extension.
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
Post Reply
tusiromania
Posts: 27
Joined: Tue Feb 04, 2020 11:09 pm

Multiple Loops in iMacros for Chrome

Post by tusiromania » Sun Oct 09, 2022 9:13 am

Can anywone give an direction on my problem?

I am forced to use Chrome browser, because of limitation of other browsers using iMacros,I think my problem can be solved easily with javascript, but chrome don't support this, firefox support .js but not supporting EVENT.

I have an .iim and I need to loop through 10 rows from one csv, make the job and then to change the account from another csv with 20 acounts, and off course to keep the loop of the accounts.

How can I do that with .iim only?

The original .iim execute around 1600 lines for all ten rows. are 10 rows and 7 columns.

My csv looking like this

Code: Select all

10/10/2022	12:15 AM	 5:00 AM	10:00 AM	12:15 PM 	5:00 PM	10:00 PM
10/11/2022	12:15 AM	 5:00 AM	10:00 AM	12:15 PM 	5:00 PM	10:00 PM
10/12/2022	12:15 AM	 5:00 AM	10:00 AM	12:15 PM 	5:00 PM	10:00 PM
10/13/2022	12:15 AM	 5:00 AM	10:00 AM	12:15 PM 	5:00 PM	10:00 PM
10/14/2022	12:15 AM	 5:00 AM	10:00 AM	12:15 PM 	5:00 PM	10:00 PM
10/15/2022	12:15 AM	 5:00 AM	10:00 AM	12:15 PM 	5:00 PM	10:00 PM
10/16/2022	12:15 AM	 5:00 AM	10:00 AM	12:15 PM 	5:00 PM	10:00 PM
10/17/2022	12:15 AM	 5:00 AM	10:00 AM	12:15 PM 	5:00 PM	10:00 PM
10/18/2022	12:15 AM	 5:00 AM	10:00 AM	12:15 PM   5:00 PM	10:00 PM
all that 1600 lines in my .iim do the job for 1 date and then loop to the next row and do the same thing


2 Solutions came to my head is to add all data in 1 csv, but i need to log in after each loop and to repeat the name of the account on each row.

Second is to copy paste my code 10 times, and get 16000 lines, using Java Eval to get the tommorow date and so on, and use only 1 datesource with the accounts. But will be so many lines and iMacros will play so hard.

This solution is not so handy...



LATER EDIT: I just resolved to not use anymore 1 database, the CSV structure I show above with dates and hours

now I just need to find the best way how to Login to new account from 60 to 60 loops

Code: Select all

 ' loop between hours
 SET orasteps EVAL("var n='{{!LOOP}}'; var x,y,z; x=n%6; if(x==0){z=6;} else{z=x;}; z;")
 SET ora "_12:15<SP>AM_5:00<SP>AM_10:00<SP>AM_12:15<SP>PM_5:00<SP>PM_10:00<SP>PM_"
 SET ora EVAL("var n='{{orasteps}}', x='{{ora}}'; var z=x.split('_'); z[n];")
 
 
 'loop between dates
 
SET day1 EVAL("var today = new Date(); var tomorrow = new Date(); tomorrow.setDate(today.getDate() + 1); var day = tomorrow.getDate().toString(); if (day.length < 2) {day = \"0\" + day;} var month = (tomorrow.getMonth() + 1).toString(); if (month.length < 2) {month = \"0\" + month;} var year = tomorrow.getFullYear().toString(); var tomorrowDateString = month + \"/\" + day + \"/\" + year; tomorrowDateString;")
SET day2 EVAL("var today = new Date(); var tomorrow = new Date(); tomorrow.setDate(today.getDate() + 2); var day = tomorrow.getDate().toString(); if (day.length < 2) {day = \"0\" + day;} var month = (tomorrow.getMonth() + 1).toString(); if (month.length < 2) {month = \"0\" + month;} var year = tomorrow.getFullYear().toString(); var tomorrowDateString = month + \"/\" + day + \"/\" + year; tomorrowDateString;")
SET day3 EVAL("var today = new Date(); var tomorrow = new Date(); tomorrow.setDate(today.getDate() + 3); var day = tomorrow.getDate().toString(); if (day.length < 2) {day = \"0\" + day;} var month = (tomorrow.getMonth() + 1).toString(); if (month.length < 2) {month = \"0\" + month;} var year = tomorrow.getFullYear().toString(); var tomorrowDateString = month + \"/\" + day + \"/\" + year; tomorrowDateString;")
SET day4 EVAL("var today = new Date(); var tomorrow = new Date(); tomorrow.setDate(today.getDate() + 4); var day = tomorrow.getDate().toString(); if (day.length < 2) {day = \"0\" + day;} var month = (tomorrow.getMonth() + 1).toString(); if (month.length < 2) {month = \"0\" + month;} var year = tomorrow.getFullYear().toString(); var tomorrowDateString = month + \"/\" + day + \"/\" + year; tomorrowDateString;")
SET day5 EVAL("var today = new Date(); var tomorrow = new Date(); tomorrow.setDate(today.getDate() + 5); var day = tomorrow.getDate().toString(); if (day.length < 2) {day = \"0\" + day;} var month = (tomorrow.getMonth() + 1).toString(); if (month.length < 2) {month = \"0\" + month;} var year = tomorrow.getFullYear().toString(); var tomorrowDateString = month + \"/\" + day + \"/\" + year; tomorrowDateString;")
SET day6 EVAL("var today = new Date(); var tomorrow = new Date(); tomorrow.setDate(today.getDate() + 6); var day = tomorrow.getDate().toString(); if (day.length < 2) {day = \"0\" + day;} var month = (tomorrow.getMonth() + 1).toString(); if (month.length < 2) {month = \"0\" + month;} var year = tomorrow.getFullYear().toString(); var tomorrowDateString = month + \"/\" + day + \"/\" + year; tomorrowDateString;")
SET day7 EVAL("var today = new Date(); var tomorrow = new Date(); tomorrow.setDate(today.getDate() + 7); var day = tomorrow.getDate().toString(); if (day.length < 2) {day = \"0\" + day;} var month = (tomorrow.getMonth() + 1).toString(); if (month.length < 2) {month = \"0\" + month;} var year = tomorrow.getFullYear().toString(); var tomorrowDateString = month + \"/\" + day + \"/\" + year; tomorrowDateString;")
SET day8 EVAL("var today = new Date(); var tomorrow = new Date(); tomorrow.setDate(today.getDate() + 8); var day = tomorrow.getDate().toString(); if (day.length < 2) {day = \"0\" + day;} var month = (tomorrow.getMonth() + 1).toString(); if (month.length < 2) {month = \"0\" + month;} var year = tomorrow.getFullYear().toString(); var tomorrowDateString = month + \"/\" + day + \"/\" + year; tomorrowDateString;")
SET day9 EVAL("var today = new Date(); var tomorrow = new Date(); tomorrow.setDate(today.getDate() + 9); var day = tomorrow.getDate().toString(); if (day.length < 2) {day = \"0\" + day;} var month = (tomorrow.getMonth() + 1).toString(); if (month.length < 2) {month = \"0\" + month;} var year = tomorrow.getFullYear().toString(); var tomorrowDateString = month + \"/\" + day + \"/\" + year; tomorrowDateString;")
SET day10 EVAL("var today = new Date(); var tomorrow = new Date(); tomorrow.setDate(today.getDate() + 10); var day = tomorrow.getDate().toString(); if (day.length < 2) {day = \"0\" + day;} var month = (tomorrow.getMonth() + 1).toString(); if (month.length < 2) {month = \"0\" + month;} var year = tomorrow.getFullYear().toString(); var tomorrowDateString = month + \"/\" + day + \"/\" + year; tomorrowDateString;")



SET dayteps EVAL("var n='{{!LOOP}}'; var x,y,z; x=n%60; if(x==0){z=60;} else{z=x;}; z;")
SET day "_{{day1}}_{{day1}}_{{day1}}_{{day1}}_{{day1}}_{{day1}}_{{day2}}_{{day2}}_{{day2}}_{{day2}}_{{day2}}_{{day2}}_{{day3}}_{{day3}}_{{day3}}_{{day3}}_{{day3}}_{{day3}}_{{day4}}_{{day4}}_{{day4}}_{{day4}}_{{day4}}_{{day4}}_{{day5}}_{{day5}}_{{day5}}_{{day5}}_{{day5}}_{{day5}}_{{day6}}_{{day6}}_{{day6}}_{{day6}}_{{day6}}_{{day6}}_{{day7}}_{{day7}}_{{day7}}_{{day7}}_{{day7}}_{{day7}}_{{day8}}_{{day8}}_{{day8}}_{{day8}}_{{day8}}_{{day8}}_{{day9}}_{{day9}}_{{day9}}_{{day9}}_{{day9}}_{{day9}}_{{day10}}_{{day10}}_{{day10}}_{{day10}}_{{day10}}_{{day10}}_"
SET day EVAL("var n='{{dayteps}}', x='{{day}}'; var z=x.split('_'); z[n];")

Now I try an workaround with a code made by @chivracq
I need to login from 60 to 60 loops to the new account,

CSV structure

Code: Select all

Account 1
Account 2
...
Account 20
I am working on this code made by @chivracq , but I Have a problem, hope soon will respond to my reply from where I got the code. Problem is if I don't declare Loops, will return random numbers.. I need to return empty and to get error.

Or maybe someone have a better idea how to login to the new account after 60 loops of iMacros code.

Code: Select all

VERSION BUILD=8820413 RECORDER=FX
TAB T=1
SET !DATASOURCE accounts.csv
 
SET !VAR1 "a1='1', a1='61', a1='121', a1='181', a1='241', a1='301', a1='361', a1='421', a1='501', a1='561', a1='621', a1='681'"
SET !VAR2 "b1='1', b1='2', b1='3', b1='4', b1='5', b1='6', b1='7', b1='8', b1='9', b1='10', b1='11', b1='12'"


SET !VAR3 EVAL("var s='{{!LOOP}}', brh='{{!VAR1}}', brc='{{!VAR2}}'; var x,y,z; x=brh.split(s); y=x[0].split(',').length; z=brc.split(',')[y-1].split('\\'')[1]; z;")
PROMPT LOOP:<SP>_{{!LOOP}}_VAR3:<SP>_{{!VAR3}}_<BR>brh:<BR>__{{!VAR1}}_<BR><BR>brc:<BR>_{{!VAR2}}_<BR><BR>

SET !DATASOURCE_LINE {{!VAR3}}






LATER EDIT: @chivracq made my day and helped me with this Modulo[60]. Amazing :) will help me o change the accounts from 60 to 60 loops.

Code: Select all


SET !ERRORIGNORE YES
SET DS_Line_Mod60 EVAL("var n='{{!LOOP}}'; var z; if((n%60)==1){z=((n-1)/60)+1;} else{z=0;}; z;")
PROMPT LOOP:<SP>_{{!LOOP}}_<BR>DS_Line_Mod60:<SP>_{{DS_Line_Mod60}}_

I am using (FCI):

Code: Select all

 iMacros for CR v10.1.1 'PE', CR v105.0.5195.102 (_x64), Win10_x64. ('CR' = 'Chrome' / 'PE' = 'Personal Edition')
 
Post Reply