I looked over this and both those code examples are not really good in actual implementation.
A Dictionary list has no inherent order and should only really be used when using keywords and values or when trying to prevent duplicate entries(like when you take in parameters)
A "redim preserve" is relatively expensive computationally, but the difference between adding 1 item and adding 50 items is insignificant.
Therefore it's far better to allocate far more slots then you expect to use, and to use a "HighWaterMark" to keep track of the end of the actual array(vs the array and the rest of the buffered slots)
option explicit
Dim arrFileLines()
parseFileToArray "c:\boot.ini", arrFileLines
'echoArraySimple arrFileLines
echoArrayNice arrFileLines
wscript.quit
'=====
sub parseFileToArray(byVal pFilename, byRef pArray)
'open - declare variables and stuff
dim objFSO,objFile, hwmArray,x 'hwm = HighWaterMark
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(pFilename, ForReading)
CONST ForReading = 1
CONST INIT = 100 'INIT = Inital Array Size
CONST EXP = 250 'EXP = expand the array by this much if it fills up
'main - do the work
hwmArray = -1
redim pArray(INIT)
Do Until objFile.AtEndOfStream
hwmArray = hwmArray + 1
x = hwmArray
if hwmArray >= ubound(pArray) then redim preserve pArray(hwmArray + EXP) 'if the array fills up, buffer EXP more entries
pArray(x) = objFile.ReadLine
Loop
redim preserve pArray(hwmArray) 'shrink array to actual size
'close - set the return value, close objects and stuff
objFile.Close
set objFile = nothing
set objFSO = nothing
end sub
'=====
sub echoArraySimple(byRef pArray)
dim strLine
For Each strLine in pArray
WScript.Echo strLine
Next
end sub
'=====
sub echoArrayNice(byRef pArray)
dim strLine,msg
For Each strLine in pArray
msg = msg & strLine & vbCRLF
Next
wscript.echo msg
end sub
there are 3 subs in this code,
one reads in the file line by line and puts it into the array you pass it.
one just runs through the array you pass it and echo's each item.
one runs through the array, puts a "vbCRLF"(newline) after each of the entries, stores them in a "msg" variable and then echo's that all at once to make it look nice.
to see the difference in output use WScript instead of CScript.