views:

2895

answers:

1

I have a rather large list of data that contains 5 properties per element. The elements are separated by a ";". I want to read the elements into an array in VBScript. Seems simple enough to search for this on the big G but all clear examples assume you want to read line by line and then split the contents on a line on a ";" character. I do not care how many lines there are until the ";" I just want all the info (in this case 5 property fields) for each element to be in one array element.

Source file looks like this:

element1 property1 = blah
element1 property2 = blah
element1 property3 = blah
element1 property4 = blah
element1 property5 = blah
;element2 property1 = blah
element2 property2 = blah
element2 property3 = blah
element2 property4 = blah
element2 property5 = blah
;element3 property1 = blah
element3 property2 = blah
element3 property3 = blah
element3 property4 = blah
element3 property5 = blah

What I want to have happen is that my VBScript array(0) be

"element1 property1 = blah
element1 property2 = blah
element1 property3 = blah
element1 property4 = blah
element1 property5 = blah"

Any ideas on how to do this. I have made several attempts at the SPLIT function using stuff like

array = Split(objTextFile.Readline , ";")

But to no avail.

+6  A: 
array = Split(objTextFile.ReadAll(), ";")
EBGreen
Wow, okay that is neato. I did not know VBScript had a ReadAll option. However when I run this I get a "Type Mismatch" error on that line. I have declared my array and set its size correctly.
wergeld
Don't set the size ahead of time.
EBGreen
Aha! thanks a bunch for that. I got a little ahead of myself there.
wergeld