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.

Moderators: Community Moderators, iMacros Moderators

Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the Google search box (at the top of each forum page) to see if a similar problem or question has already been addressed. This will search the entire contents of the forums as well as the iMacros Wiki.
3. We can respond much faster to your posts if you include the following information:

CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST

Answering your own posts (e.g. attempting to "bump" your topic) drops your topic from the list of unanswered threads, so it may actually receive less views.

LOOPs are throwing me for a loop...

by ltek on Fri Sep 23, 2005 3: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?
ltek
 
Posts: 45
Joined: Thu Sep 22, 2005 12:52 pm

by Tech Support on Fri Sep 23, 2005 3:21 pm

The macro looks ok - what error do you get?
User avatar
Tech Support
 
Posts: 5003
Joined: Tue Sep 20, 2005 12:25 pm

by ltek on Fri Sep 23, 2005 3: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
ltek
 
Posts: 45
Joined: Thu Sep 22, 2005 12:52 pm

by Tech Support on Fri Sep 23, 2005 4: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/Member.asp?PubID={{!col3}}{{!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 Mon Oct 29, 2007 5:41 pm, edited 1 time in total.
User avatar
Tech Support
 
Posts: 5003
Joined: Tue Sep 20, 2005 12:25 pm

by ltek on Fri Sep 23, 2005 4: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.
ltek
 
Posts: 45
Joined: Thu Sep 22, 2005 12:52 pm

by Tech Support on Fri Sep 23, 2005 5:11 pm

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.
User avatar
Tech Support
 
Posts: 5003
Joined: Tue Sep 20, 2005 12:25 pm

by ltek on Sun Sep 25, 2005 4: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
ltek
 
Posts: 45
Joined: Thu Sep 22, 2005 12:52 pm

by Tech Support on Mon Sep 26, 2005 6:41 am

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.
User avatar
Tech Support
 
Posts: 5003
Joined: Tue Sep 20, 2005 12:25 pm


Return to General Support & Discussions

Who is online

Users browsing this forum: No registered users and 10 guests

-->