I need to read a text file in chunks so that I don't need show too much information on screen at once.
I need that the user can see the next chunk from result set as he click next button (each chunk are separated by next keyword).
I tried it showing in table but that was quite unreadable for user Read text file and show in table vbscript
My text file as given below :-
C:\Users\abc\Desktop\New Folder\sample.txt
AccountName->AbcPos
AccountName->dblLayer
queryAccount->qskxyz
queryName->qixyz
queryName->abc
queryName->def
next
C:\Users\abc\Desktop\New Folder\New folder\sample3.txt
AccountName->AbcPos
AccountName->dblLayer
queryAccount->qskxyz
queryName->qixyz
AccountName->Names
AccountName->prelLayer
queryAccount->serchTerm
queryName->myName1
next
C:\Users\abc\Desktop\New Folder\sample1.txt
AccountName->AbcPos
AccountName->dblLayer
queryAccount->qskxyz
queryName->qixyz
next
C:\Users\abc\Desktop\New Folder\sample2.txt
AccountName->AbcPos
AccountName->dblLayer
queryAccount->qskxyz
queryName->qixyz
queryName->abc
queryName->def
AccountName->Names
AccountName->prelLayer
queryAccount->serchTerm
queryName->myName1
next
I can read the file as textStream but facing problem in reading it by portion.
Option Explicit
Const csSep = "->"
Dim oFS : Set oFS = CreateObject("Scripting.FileSystemObject")
Dim oTS : Set oTS = oFS.OpenTextFile("..\data\36060599.txt")
ReDim aData(4)
Do Until oTS.AtEndOfStream
Dim sLine : sLine = Trim(oTS.ReadLine())
Dim sValue : sValue = ""
If InStr(sLine, csSep) Then sValue = Split(sLine, csSep)(1)
Select Case True
Case ":" = Mid(sLine, 2, 1) ' the Path
aData(0) = sLine
Case "AccountName" = Left(sLine, 11)
aData(2 + IsEmpty(aData(1))) = sValue
Case "queryAccount" = Left(sLine, 12)
aData(3 + IsEmpty(aData(1))) = sValue
Case "queryName" = Left(sLine, 9)
aData(4 + IsEmpty(aData(1))) = sValue
Case "next" = sLine ' End Of Record
' WScript.Echo "<tr><td>" & Join(aData, "</td><td>") & "</td></tr>"
WScript.Echo "|" & Join(aData, "|") & "|"
ReDim aData(4)
End Select
Loop
oTS.Close