How to Loop multiple times with CVS?

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
Forum rules
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
Vitae
Posts: 64
Joined: Wed Jan 14, 2009 2:45 am

How to Loop multiple times with CVS?

Post by Vitae » Thu Aug 15, 2013 11:41 pm

For part of my job I'm given a daily list of Job reqs that I'm supposed to monitor throughout the day and alert people if a particular req has been put on hold or closed.

Code: Select all

VERSION BUILD=8300326 RECORDER=FX
SET !TIMEOUT 30
TAB T=1
CMDLINE !DATASOURCE jobreqs.csv
SET !DATASOURCE_COLUMNS 1
SET !LOOP 2
SET !DATASOURCE_LINE {{!LOOP}}
SET !REPLAYSPEED SLOW
URL GOTO=https://www.fieldglass.net/
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:loginForm ATTR=NAME:username CONTENT=MyUserName
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:loginForm ATTR=NAME:action&&VALUE:Log<SP>In
TAG POS=1 TYPE=INPUT:TEXT ATTR=* CONTENT={{!COL1}}
TAG POS=1 TYPE=DIV ATTR=TITLE:Search&&ONCLICK:globalSearchForDocument()&&CLASS:globalSearchImg&&TXT:
SET !REPLAYSPEED FAST
The problem is, is that obviously with this method I have to manually run it everytime I want to do it.

I thought about running the jobreqs along the columns and just repeating in the rows the same #'s, but honestly having this 50 - 100 times

Code: Select all

TAG POS=1 TYPE=INPUT:TEXT ATTR=* CONTENT={{!COL1}}
TAG POS=1 TYPE=DIV ATTR=TITLE:Search&&ONCLICK:globalSearchForDocument()&&CLASS:globalSearchImg&&TXT:
TAG POS=1 TYPE=INPUT:TEXT ATTR=* CONTENT={{!COL2}}
TAG POS=1 TYPE=DIV ATTR=TITLE:Search&&ONCLICK:globalSearchForDocument()&&CLASS:globalSearchImg&&TXT:
TAG POS=1 TYPE=INPUT:TEXT ATTR=* CONTENT={{!COL3}}
TAG POS=1 TYPE=DIV ATTR=TITLE:Search&&ONCLICK:globalSearchForDocument()&&CLASS:globalSearchImg&&TXT:
TAG POS=1 TYPE=INPUT:TEXT ATTR=* CONTENT={{!COL4}}
TAG POS=1 TYPE=DIV ATTR=TITLE:Search&&ONCLICK:globalSearchForDocument()&&CLASS:globalSearchImg&&TXT:
would REALLY start to look ugly as hell, and I'd have to constantly change it every day since I get different #'s of reqs to monitor. But I could add a Wait Seconds to the end of it and it would loop that way :)

Code: Select all

VERSION BUILD=8300326 RECORDER=FX
SET !TIMEOUT 30
TAB T=1
SET !DATASOURCE jobreqs.csv
SET !DATASOURCE_COLUMNS #needed
SET !DATASOURCE_LINE {{!LOOP}}
SET !REPLAYSPEED SLOW
TAG POS=1 TYPE=INPUT:TEXT FORM=NAME:loginForm ATTR=NAME:username CONTENT=MyUserName
TAG POS=1 TYPE=INPUT:SUBMIT FORM=NAME:loginForm ATTR=NAME:action&&VALUE:Log<SP>In
TAG POS=1 TYPE=INPUT:TEXT ATTR=* CONTENT={{!COL1}}
TAG POS=1 TYPE=DIV ATTR=TITLE:Search&&ONCLICK:globalSearchForDocument()&&CLASS:globalSearchImg&&TXT:
TAG POS=1 TYPE=INPUT:TEXT ATTR=* CONTENT={{!COL2}}
TAG POS=1 TYPE=DIV ATTR=TITLE:Search&&ONCLICK:globalSearchForDocument()&&CLASS:globalSearchImg&&TXT:
'* * * * * * * * * E T C * * * * * * * * *
SET !REPLAYSPEED FAST
WAIT SECONDS=1800
Plus, I already know that the longer a .iim script is, and the longer it's running, the more chance for it to suddenly seize up.
I know the .js way is much better and less chance of problems from what I've seen on here.

How would I, if I can, set this up in JS so that I could run it all day every 30 minutes which is 16 times a day?
I know that with 2 vars I can set one for how many total loops (16), and the other for the # of reqs (50 - 100), but I really don't understand the workings of all of that. :(
Looking at the example scripts, I see "push" and "play" and lots of other stuff that that really makes my head swim :oops:
If anyone can help me, that would be great. Not looking for a moderator to help (tho that would be grand), but someone from the community that can help.
Marcia, Tech Support
Posts: 1095
Joined: Thu Jan 29, 2009 1:10 pm

Re: How to Loop multiple times with CVS?

Post by Marcia, Tech Support » Fri Aug 16, 2013 8:01 am

Hi,

The best solution is to leave all this timing and looping to an external program or script, like vbs. The script would then use iMacros Scripting Interface to open the browser at given times, run the requests and close the browser again.

Or, you can use Windows Scheduler to start iMacros for Firefox from a command line.
Regards,

Marcia
Vitae
Posts: 64
Joined: Wed Jan 14, 2009 2:45 am

Re: How to Loop multiple times with CVS?

Post by Vitae » Fri Aug 16, 2013 2:25 pm

Ok, so the best option is to pay for the full imacros software or use another program to use imacros.

I'll stick with the last method I said then with running them across and just editing the file as needed.
Thanks anyways :(
chivracq
Posts: 8765
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: How to Loop multiple times with CVS?

Post by chivracq » Fri Aug 16, 2013 5:17 pm

OK, I'll give it a few thoughts...

You could leave the Timing to the (Windows) Task Scheduler, set up a Task every morning at 9h00 and repeat it 15 times every 30 min, like that you can even be late at your work or be sick, nobody will even notice... (And you've made yourself nearly redundant!) The .CSV file needs to be saved on some central network drive by your boss before 9h that your Macro can access...
The Task will be to run your IIM Macro from a Batch File. Example here:
http://forum.imacros.net/viewtopic.php?f= ... 329#p52855
http://forum.imacros.net/viewtopic.php?f= ... 126#p53056

Then I don't find your idea to handle the Looping "horizontally" with !COL1/!COL2/.../!COL100 that stupid... And you don't need to modify your Script everyday, as long as you've included 100 Blocks in it...
Your Script will abort automatically at COL51 if there is some Javascript Validation on the Page when searching for an empty Doc_Ref or you can add some !ONDIALOG handling and/or !ERRORIGNORE... and it will otherwise attempt 50 times (2-3 min with "SET !TIMEOUT_STEP 1" and your "SET !REPLAYSPEED SLOW") to fetch a Doc with an empty Doc_Ref, but who cares...!

Another advantage to that "horizontal" Looping is that it speeds up the Looping as you don't log in to the Site at each Loop, you could have split your original IIM Macro into 2 IIM Files, one for the login to the Site, and one for the rest, and called them both from a .JS File (that you would then call from the Batch File...).

Other approach if you still find the "horizontal" Looping too ugly, it still to have a .JS File calling the 2 IIM Files (Login and Doc_Fetch) with Doc_Fetch fetching only 1 Doc and you handle the Looping of Doc_Fetch yourself in the .JS File, but you need to increment the !LOOP Counter for !DATASOURCE_LINE yourself... (And the Timing still handled by the Scheduler...)
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply