Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do Loop Trouble

Status
Not open for further replies.

Kreiss

Programmer
Oct 8, 2003
48
0
0
US
I have the following code and getting an "Object doesn't support this method: 'ts.EOF'" error. It works fine without the loop, but i really need it to go through the whole file and it would never be the same number of records. I would appreciate if someone could give me some help.

Thanks in advance,
Kacy

[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=
[PCOMM SCRIPT SOURCE]
OPTION EXPLICIT
autECLSession.SetConnectionByName(ThisSessionName)

REM This line calls the macro subroutine
subSub1_

sub subSub1_()
autECLSession.autECLOIA.WaitForAppAvailable

Dim fso, f1, ts, s
Const ForReading = 1
Set fso = CreateObject("Scripting.FileSystemObject")
Set f1 = fso.CreateTextFile("c:\testfile.txt", True)
' Write a line.

f1.WriteLine "R99999999999"
f1.WriteLine "R99999999999"

' Read the contents of the file.

Set ts = fso_OpenTextFile("c:\testfile.txt", ForReading)

Do While Not ts.EOF

s = ts.ReadLine
autECLSession.autECLPS.SendKeys "DLN/"+s+".PM1."
autECLSession.autECLPS.SendKeys"[Enter]"
autECLSession.autECLPS.SendKeys"[Clear]"

ts.MoveNext
Loop

ts.Close


end sub

 
Text streams use "TS.AtEndOfStream" ... not "TS.EOF". Also, there is no "TS.MoveNext" method. The equivalent is accomplished by "TS.ReadLine" which you already have in your code.
 
Hello Kreiss,

Additional note:
You need to close the f1 before reopen the file for reading.
Code:
f1.WriteLine "R99999999999"
[COLOR=red] f1.close[/color]
   ' Read the contents of the file.
  
   Set ts = fso.OpenTextFile("c:\testfile.txt", ForReading)
regards - tsuji
 
Thank you guys very much. I was having the same problem, did not realize no EOF for text file.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top