Need a script to display line 17 of text file
As the title says. If you're feeling especially generous, you could toss in a few lines so that the user is prompted for the filename as well
Thanks [:D]
Thanks [:D]
0 Comments
[ + ] Show comments
Answers (3)
Please log in to answer
Posted by:
WiseUser
19 years ago
This should work... If you ever get generous enough to share your salary with me, I'll think about your other request.[;)]
Msgbox sReadLine("C:\Boot.ini", 2)
Function sReadLine(sFilePath, iLine)
Dim oFso, i, hReadFile
Set oFso = CreateObject("Scripting.FileSystemObject")
Err.Clear
Set hReadFile = oFso.OpenTextFile(sFilePath, 1, False)
If Err.Number <> 0 Then sReadLine = "Error" : Exit Function
Do Until hReadFile.AtEndofStream
i = i + 1
sReadString = hReadFile.ReadLine
If i = iLine Then sReadLine = sReadString : Exit Function
If i > iLine Then sReadLine = "Not found" : Exit Function
Loop
If sReadLine = "" Then sReadLine = "Not found" : Exit Function
Set hReadFile = Nothing
Set oFso = Nothing
End Function
Function sReadLine(sFilePath, iLine)
Dim oFso, i, hReadFile
Set oFso = CreateObject("Scripting.FileSystemObject")
Err.Clear
Set hReadFile = oFso.OpenTextFile(sFilePath, 1, False)
If Err.Number <> 0 Then sReadLine = "Error" : Exit Function
Do Until hReadFile.AtEndofStream
i = i + 1
sReadString = hReadFile.ReadLine
If i = iLine Then sReadLine = sReadString : Exit Function
If i > iLine Then sReadLine = "Not found" : Exit Function
Loop
If sReadLine = "" Then sReadLine = "Not found" : Exit Function
Set hReadFile = Nothing
Set oFso = Nothing
End Function
Posted by:
Bladerun
19 years ago
Posted by:
WiseUser
19 years ago
Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.
so that the conversation will remain readable.