Hey guys,
Just a quick question, I have some code that reads in a line from a text file. the line of text contains various pieces of data all seperated by a “;”. Is there a quick way to scan the string for the ";"s and then seperate the information out into a multi-dimension array;
Sample from text file;
0.384615384615385;0.0833333333333333;0.634615384615385;0;AA01
What I want is to have an array like this;
Array(1,1)=0.384615384615385
Array(1,2)=0.0833333333333333
Array(1,3)=0.634615384615385
Array(1,4)=0
Array(1,5)=AA01
I have some code working but its not overly efficient, basically there is a series of for loops that scroll through the text looking for the “;” and then taking the information behind that into each array. then the next loop starts at 1 on from where the last one finish.
is there a more efficent way to do this as well as have it work for a varying number of pieces of data in each line (i.e. in the above example each line has 5 pieces, what about increasing it to 6 or 7?)
Any help would be great
here is my current code;
[code] for a=1 to rectangles
input=SourceStream.Readline
for b=1 to len(input)
if mid(input,b,1)=";" then
rectangle_data(a,1)=left(input,b-1)
exit for
end if
next
for c=b+1 to len(input)
if mid(input,c,1)=";" then
rectangle_data(a,2)=mid(input,b+1,(c-b-1))
exit for
end if
next
for d=c+1 to len(input)
if mid(input,d,1)=";" then
rectangle_data(a,3)=mid(input,c+1,(d-c-1))
exit for
end if
next
for e=d+1 to len(input)
if mid(input,e,1)=";" then
rectangle_data(a,4)=mid(input,d+1,(e-d-1))
rectangle_data(a,5)=right(input,len(input)-d)
exit for
end if
next
next[/code]