Dear KF4GHG,
I would like to attempt to offer an insight into the problems you experience in your code.
Observation #1
dim MaxElements as long = 100 ' MaxElements is set to 100
dim vList(MaxElements) AS STRING ' vList has 100 elements
...
Dim iTm (15) As Integer ' iTm has however just 15 elements
Observation #2
InFileChannel = file_open(InFileToLoad , "INPUT" )
i = 1
while not file_eof(InFileChannel)
sBuffer = file_lineinput(InFileChannel)
print sBuffer
iTm(15) = sBuffer
i=i+1
wend
We can see in this part that sBuffer variable will contain
only the last read value from the file after leaving while cycle
Problematic part:
i = 1
FOR count = 1 TO MaxElements
' Works Fine - give Item and number
' vList(Count) = "Item " & FORMAT$(RND(1, 100000), "000000")
' Does not work - gives only "ten"
' vList(Count) = sBuffer ' "Ronnie Item " & FORMAT$(RND(1, 100000), "000000")
' Does not work - gives "Subscript out of range in array or matrix
'Dimension 1 should be between 1 and 15. Current value: 16"
vList(Count) = iTm (i) 'sBuffer ' "Ronnie Item " & FORMAT$(RND(1, 100000), "000000")
i = i+1
NEXT
The issue on line 7 is not really an issue - it gives only single value because of the fact highlighted in the Observation #2
The issue on line 11 occurs for the following reason:
- the FOR cycle goes from 1 to MaxElements, that is 1 to 100
- the i variable will also grow from 1 to 100, thanks to the way you initialize it to 1 before the cycle and increase by one at the end of the cycle
- the iTm array is dimensioned just for 15 elements, as seen in Observation #1
I hope this helps getting you closer to your goal.
Petr
Bookmarks