China DOS Union

-- Unite DOS · Advance DOS · Grow DOS --

Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum
DOS stands for freedom, openness and progress. Let us work hard, learn from the openness and GNU spirit of FreeDOS and Linux, and together build and grow a free GNU GPL world!

中国DOS联盟论坛
The time now is 2026-08-02 02:26
中国DOS联盟论坛 » DOS批处理 & 脚本技术(批处理室) » How to read the content of a text file into a two-dimensional array using VBS&JS View 1,881 Replies 3
Original Poster Posted 2006-08-24 15:58 ·  中国 江苏 苏州 电信
中级用户
★★
过度热情
Credits 321
Posts 139
Joined 2006-03-21 17:19
20-year member
UID 52521
Gender Male
Status Offline
As the title says.!
C language can conveniently read a 2D array, but how to implement it with VBS and JS?

It seems that VBS all have functions to read a line, readline, read. Does it have a function to directly specify the character in the nth line and nth column of the file?
For JS, similar to C, does it have such a ready-made function?
知识在于不断积累
Floor 2 Posted 2006-08-26 08:59 ·  中国 江苏 苏州 电信
中级用户
★★
过度热情
Credits 321
Posts 139
Joined 2006-03-21 17:19
20-year member
UID 52521
Gender Male
Status Offline
知识在于不断积累
Floor 3 Posted 2006-08-27 19:52 ·  中国 湖北 荆门 电信
荣誉版主
★★★
Credits 2,013
Posts 718
Joined 2006-02-18 07:07
20-year member
UID 50550
Status Offline
In VBS, you can easily achieve reading specified content of a file by using the skipline method, readline method of the Scripting.FileSystemObject object and the Mid function:


Function GetStr(strFile,intRow,intCol)

With CreateObject("Scripting.FileSystemObject").OpenTextFile(strFile)
For i = 1 To intRow - 1
.skipline
Next
strTmp = .readline
GetStr = Mid(strTmp,intCol,1)
End With

End Function

For reading file content into a two-dimensional array, you can use ADO to implement.
Floor 4 Posted 2006-08-28 10:25 ·  中国 江苏 苏州 电信
中级用户
★★
过度热情
Credits 321
Posts 139
Joined 2006-03-21 17:19
20-year member
UID 52521
Gender Male
Status Offline
Thanks.. But the above code doesn't do the judgment of the end of the file. Currently, the key problem I encounter is that VBS judges the end-of-line character of a file. In this way, I can judge how many lines an unknown file has. There is a AtEndOfLine for judging a line end in VBS, but I can't find the function for judging the end of the file. Please help... Thanks in advance.!!!!!!!!!!!
知识在于不断积累
Forum Jump: