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!

Cannot read a text file 1

Status
Not open for further replies.

JazzFan

Technical User
Apr 8, 2003
18
0
0
US
Hi everyone,
I am trying to read a file line by line but my script is just not cooperating. Can anyone please point out what I am missing?
Here's what I have:

'Option Explicit
Const INPUT_FILE_NAME = "C:\scripts\wmi\testers\XPLibrarySongList.txt"
Const FOR_READING = 1
On Error Resume Next

Const E_ADS_PROPERTY_NOT_FOUND = &h8000500D
Dim objFSO,objFile,strSongLine

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(INPUT_FILE_NAME, FOR_READING)

Do Until objFile.AtEndOfStream
strSongLine = objFile.ReadLine
If Err.Number <> 0 Then
Wscript.Echo strSongLine & " " & Err.Description & " " & Err.Number
Err.Clear
Else
wscript.Echo "Found " & strSongLine

End if

' Wscript.Echo strSongLine
' strSongTitle = Left(strSongLine, 45)
' Trim(strSongTitle)

' If Err.Number <> 0 Then
' Wscript.Echo strSongTitle & " " & Err.Description & " " & Err.Number
' Err.Clear
' Else
' wscript.Echo "Editing description field for " & strSongTitle
'
' End if


Loop
objFile.Close

When I run the script all I get is the word Found but not the rest of the line of text. Each line in the text file is a little over 200 characters wide.
Thanks in advance for your help
jazzfan
 
Hello JazzFan,

If then, try this?
[tt]
Set objFile = objFSO.OpenTextFile(INPUT_FILE_NAME, FOR_READING, vbtrue, vbtrue)
[/tt]
regards - tsuji
 
Hello tsuji, I am very grateful for your prompt and accurate response. It worked like a charm.
Thanks again and have a star.
jazzfan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top