Do .. While EOF loop for VBScript

Discussions and Tech Support related to automating the iMacros Browser or Internet Explorer from any scripting and programming language, such as VBS (WSH), VBA, VB, Perl, Delphi, C# or C++.

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.

Do .. While EOF loop for VBScript

by muguk on Fri Nov 07, 2008 8:31 am

I've used the example as given with the full Scripting Edition to create my macro (as below) but I'd like to change it from a set number of iterations into a "do every line until the end of the file is reached" .. how can I convert the code to do this? It's fine for testing purposes as my CSV file only has 3 entries but when it's released to those who are going to be using it, it's going to be playing with a lot more entries.

Code: Select all
Option Explicit
 
' MsgBox "Test of controlling the iMacros - feeding it via a CSV file."
 
 Dim iim1, i, iret
 
 set iim1= CreateObject ("imacros")
 iret = iim1.iimInit
 iret = iim1.iimDisplay("Submitting Data")
 
 'Note: The input file name and the number of columns are specified in the macro
 'You can also specify them inside the script with "iimSet"
 
 'Loop through the input file

 ' Does 3 records - change to relevant values later on

 for i = 1 to 3
    'Set the current read position
    iret = iim1.iimSet("-var_line", cstr(i))
 
    'Run the macro
    iret = iim1.iimPlay("[i]my macro[/i]")
 
 'Check if user wants to stop
 if iret = - 3 or iret = - 5 Then
     MsgBox "User closed browser"
     WScript.Quit(0)
 End If
   
 If iret < 0 Then
       MsgBox iim1.iimGetLastError()
    End If
 next
 
 iret = iim1.iimDisplay("Done!")
 iret = iim1.iimExit
 WScript.Quit(0)
muguk
 
Posts: 5
Joined: Tue Nov 04, 2008 4:32 am
Location: Stockport, Cheshire. UK

Re: Do .. While EOF loop for VBScript

by Tech Support on Thu Nov 13, 2008 2:50 pm

Here is some sample code:
Code: Select all
Option Explicit
Dim oFSO, sFile, oFile, sText
Set oFSO = CreateObject("Scripting.FileSystemObject")
sFile = "your text file"
If oFSO.FileExists(sFile) Then
Set oFile = oFSO.OpenTextFile(sFile, 1)
 Do While Not oFile.AtEndOfStream
  sText = oFile.ReadLine
   If Trim(sText) <> "" Then
    WScript.Echo sText
   End If
 Loop
oFile.Close
Else
WScript.Echo "The file was not there."
End If


There are many other examples on the web, for example http://bytes.com/forum/thread647301.html
User avatar
Tech Support
 
Posts: 5003
Joined: Tue Sep 20, 2005 12:25 pm

Re: Do .. While EOF loop for VBScript

by fifabeqre on Tue Jul 21, 2015 6:09 pm

whats this
utfifas | fifa 16 coins
fifabeqre
 
Posts: 2
Joined: Tue Jul 21, 2015 5:42 pm

Re: Do .. While EOF loop for VBScript

by Baatkro1 on Tue Mar 01, 2016 2:57 am

how can I convert the code to do this? It's fine for testing purposes as my CSV file only has 3 entries but when it's released to those who are going to be using it,????




== www.solitairecardgame.info ==
Baatkro1
 
Posts: 1
Joined: Tue Mar 01, 2016 2:56 am


Return to Scripting and Command Line Interface

Who is online

Users browsing this forum: No registered users and 4 guests

-->