Page 1 of 1

LOOPs are throwing me for a loop...

Posted: Fri Sep 23, 2005 10:12 pm
by ltek
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?

Posted: Fri Sep 23, 2005 10:21 pm
by Tech Support
The macro looks ok - what error do you get?

Posted: Fri Sep 23, 2005 10:24 pm
by ltek
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

Posted: Fri Sep 23, 2005 11:41 pm
by Tech Support
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)

Posted: Fri Sep 23, 2005 11:54 pm
by ltek
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.

Posted: Sat Sep 24, 2005 12:11 am
by Tech Support
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.

Posted: Sun Sep 25, 2005 11:34 pm
by ltek
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

Posted: Mon Sep 26, 2005 1:41 pm
by Tech Support
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.