I'm using the following code to (re)initialize an array of strings:
includepath "$\inc\"
include "console.inc"
% c_maxlines = 7000
dim pgm(1 to c_maxlines) as string
sub newstmt()
dim i as integer
print("In newstmt, starting for loop" & cr)
for i = 1 to c_maxlines
print(i & " ")
pgm(i) = ""
next i
print(cr & "Returning from newstmt" & cr)
end sub
print(version & " Calling newstmt" & cr)
call newstmt()
print("Done" & cr)
getkey()
But it crashes at either 851 or 1641 rows initialized. What am I doing wrong?
This is in 040 downloaded from github.
Anyone else able to try it, to see if it works for you?
hello Ed
this code work
includepath "$\inc\"
include "console.inc"
% c_maxlines = 7000
dim pgm(c_maxlines) as string
sub newstmt()
dim i as integer
print("In newstmt, starting for loop" & cr)
for i = 1 to c_maxlines
print(i & " ")
pgm(i) = ""
next i
print(cr & "Returning from newstmt" & cr)
end sub
print("Calling newstmt" & cr)
newstmt()
print("Done" & cr)
getkey()
Yes, the dim statement was the only problem.
o2 defaults to indexbase 1 anyway
''dim pgm(1 to c_maxlines) as string
indexbase 1
dim pgm(c_maxlines) as string