LOOPs are throwing me for a loop...

Support for iMacros. The iMacros software is the unique solution for automating every activity inside a web browser, for data extraction and web testing.
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
ltek
Posts: 45
Joined: Thu Sep 22, 2005 7:52 pm

LOOPs are throwing me for a loop...

Post by ltek » Fri Sep 23, 2005 10:12 pm

my code:

Code: Select all

SET !DATASOURCE {{FILE}}
SET !LOOP 1
SET !DATASOURCE_LINE {{!LOOP}}
URL GOTO=http://member.info.com/Roster/Scripts/Member.asp?PubID={{!col3!LOOP}}
CSV file structure being passed in looks like this:

"Badi","Alan","AA023","ARIZONA BEST","BEST04","(480)111-1000"


How do I get IM to just go one-by-one though the list pulling the text from Col3 and inserting for extraction?
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Fri Sep 23, 2005 10:21 pm

The macro looks ok - what error do you get?
ltek
Posts: 45
Joined: Thu Sep 22, 2005 7:52 pm

Post by ltek » Fri Sep 23, 2005 10:24 pm

no error, it just stops after the firstline.

here's the function sending in the data to the macro...

Function Macro_ExtractMemberInfoLoop
set iim1 = CreateObject ("InternetMacros.iim")
iret = iim1.iimSet("-var_FILE", FileName)
iret = iim1.iimInit("-silent")
iret = iim1.iimDisplay("Macro Running")
iret = iim1.iimPlay("MemberInfoLoop")
iret = iim1.iimDisplay("MemberInfo Done!")
Macro_ExtractMemberInfoLoop = iim1.iimGetLastExtract()
iret = iim1.iimExit
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Fri Sep 23, 2005 11:41 pm

The !LOOP variable is only intended for use with the LOOP button or the "-loop" command line switch. With the Scripting Interface you need to make the looping yourself. But this is easy:

In the macro change:

SET !DATASOURCE {{FILE}}
SET !DATASOURCE_LINE {{!mypos}}
URL GOTO=http://member.info.com/Roster/Scripts/M ... }}{{!mypos}}


In this VBS file change:

set iim1 = CreateObject ("imacros")
iret = iim1.iimInit("-silent") '<=must be BEFORE iimSet
iret = iim1.iimDisplay("Macro Running")
iret = iim1.iimSet("-var_FILE", FileName)

'Start looping
For i = 1 to 20
'Set the current read position
iret = iim1.iimSet("-var_mypos", cstr(i))
iret = iim1.iimPlay("MemberInfoLoop")
Next

You can also see the "file-2-web.vbs" example (reads a text file and submits the content to a website)
Last edited by Tech Support on Tue Oct 30, 2007 12:41 am, edited 1 time in total.
ltek
Posts: 45
Joined: Thu Sep 22, 2005 7:52 pm

Post by ltek » Fri Sep 23, 2005 11:54 pm

I thought we could loop from within the Macro?

I have code that does looping using vbscript but due to the fact that each time the macro starts the page it must authenticate, this is very slow when we are talking hundreds of extracts.

If I could loop from within the macro then I would not need to authenticate each time.

Arg.


If I may make two suggestions...

1) Post on the web site a list of the functions that you can do within Macros and ones you must do within Script. A simple table will suffice. The help file (I have read it many times) and the example code is not very helpful and as I pointed out earlier can actually make things more confusing.

2) Impliment loops within the Macro. Without this, as I stated before, anything more advanced then a simple "serial" macro becomes near impossible and we must resort to using vbscript, thus eliminating much of what I thought the value of your software was going to provide.
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Sat Sep 24, 2005 12:11 am

I have code that does looping using vbscript but due to the fact that each time the macro starts the page it must authenticate, this is very slow when we are talking hundreds of extracts.
Solution: Split your macro into two parts: The 1st macro does the login and the 2nd macro the looping. When you do this, make sure to remove any "URL GOTO..." command from the 2nd macro, so it starts exactly where the 1st macro stops!

set iim1 = CreateObject ("InternetMacros.iim")
iret = iim1.iimPlay("do_login")
'Start looping
For i = 1 to 20
'Set the current read position
iret = iim1.iimSet("-var_mypos", cstr(i))
iret = iim1.iimPlay("do_loop")
Next
iret = iim1.iimPlay("do_logout")

Also, thanks a lot for your useful comments and feedback.
ltek
Posts: 45
Joined: Thu Sep 22, 2005 7:52 pm

Post by ltek » Sun Sep 25, 2005 11:34 pm

I cannot remove GOTO URL... since it is a different URL that is needed for each loop... thus the reason for the loop.

I need to use data from the first macro to supply for the second macro to open hundreds of different pages.

here's the steps...
* note script wraps this entire process

Macro1:
login
navigate to search page
enter search criteria
- text handed to macro by script
extract table data from search results
- extract handed back to script to clean up andwrite to CSV

Macro2:
opens numerous URLs with data extracted by first macro
- URL handed to macro by script
extracts table data one-by-one from each page and hands back to script
User avatar
Tech Support
Posts: 4948
Joined: Tue Sep 20, 2005 7:25 pm
Contact:

Post by Tech Support » Mon Sep 26, 2005 1:41 pm

You do not need to remove the URL GOTO command in your case, just editing it (=adding a variable) is ok.

I mentioned to "remove URL GOTO..." only as sometimes users forget to remove the URL... command if actually what they want is to start with macro2 exactly where macro1 stopped.
Post Reply