GH>Once and for all, I'm determined to get Huge Arrays to work under
GH>QB45. (I need them to work with strings read from a file.)
GH>Here is my first attempt (source file is 2.BAS):
GH> DIM ar(1400) AS STRING * 64
GH> OPEN "xx" FOR INPUT AS #1
GH> FOR i = 1 TO 1400
GH> LINE INPUT #1, ar(i)
GH> NEXT i: CLOSE: END
George,
Looks okay. I added the ' $DYNAMIC metacommand that will make the array
dynamic (versus static - see the QB online help for more info on -
Dynamic vs. Static arrays). Here's my test-your-code code that worked
for me in PDS 7.1
' ----------- CUT HERE -------------------------------- CUT HERE ---------
REM You must start QB\PDS with the /AH command line option for this program
' $DYNAMIC ' array space allocated when program is run - see QB onlinehelp
OPEN "xx" FOR OUTPUT AS #1
REM Create a 1400 line file with 56 character a's on each line
FOR I% = 1 TO 1400
PRINT #1, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
NEXT I%
CLOSE #1
DIM ar(1400) AS STRING * 64
OPEN "xx" FOR INPUT AS #1
FOR I = 1 TO 1400
LINE INPUT #1, ar(I) ' load up the array
NEXT I
CLOSE #1
REM Let's dump the array contents and have a look-see
FOR I% = 1 TO 1400
PRINT ar(I%)
NEXT I%
END ' All done. The End.
' ----------- CUT HERE -------------------------------- CUT HERE ---------
GH>Running QB 2 /AH gives a "Subscript out of range" error,
GH>and BC 2 /AH says "Array too big" while pointing at the
GH>64 in the first line.
GH>The file xx contains 1400 lines each consisting of the same 56
GH>characters (making it exactly 64 characters doesn't help).
Why not simply put that single line of 56 characters in the file,
read it in and then stuff it into the array 1400 times, as in:
' ------------ CUT HERE ----------------------------- CUT HERE -----------
' $DYNAMIC
TheLine$ = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
OPEN "xx" FOR OUTPUT AS #1
PRINT #1, TheLine$ ' write 1 line of data to the data file
CLOSE #1
DIM ar(1400)
OPEN "xx" FOR INPUT AS #1
LINE INPUT #1, TheLine$ ' get that single line of 56 characters
CLOSE #1
FOR I% = 1 TO 1400
ar(I%) = TheLine$ ' load up the array with the 56 character string
NEXT I%
FOR I% = 1 TO 1400 ' let's dump the array and have a look-see
PRINT ar(I%)
NEXT I%
' ------------ CUT HERE ----------------------------- CUT HERE -----------
Hope that helps. Good luck!
- Robert
* OLX 2.1 TD * "I'm mad as hell and I'm not gonna take it anymore!!!!"