Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Article Q35149
◄Contents► ◄Index► ◄Back►
─────────────────────────────────────────────────────────────────────────────
◄Knowledge Base Contents► ◄Knowledge Base Index►
How to BSAVE and BLOAD Arrays Larger Than 64K in Visual Basic -Q35149
Microsoft Visual Basic version 1.0 for MS-DOS allows the use of "huge"
dynamic arrays containing more than 64K when you compile your program
with the /AH option. However, because the BSAVE and BLOAD statements
use a 2-byte unsigned integer to record the file length, only 64K may
be contained in a BLOAD/BSAVE file. To save an area of memory larger
than 64K, you must break the region into blocks (which may overlap),
each smaller than 65,536 bytes. To BSAVE each block, it is important
to do a DEF SEG and VARPTR for the start of the region. A "Path/File
Access Error" may result if those steps are omitted.
More Information:
' You must invoke Visual Basic 1.0 for MS-DOS with the VBDOS /AH
' option.
'
' This code BSAVEs and BLOADs a 128,000 byte array.
OPTION BASE 1
DEFINT A-Z
'$DYNAMIC
DIM nums(32000, 2)
FOR k = 1 TO 32000
FOR l = 1 TO 2
nums(k, l) = k + l
NEXT l
NEXT k
DEF SEG = VARSEG(nums(1, 1))
BSAVE "star52a.sav", VARPTR(nums(1, 1)), 64000
DEF SEG = VARSEG(nums(16000, 1))
BSAVE "star52b.sav", VARPTR(nums(16000, 1)), 64000
FOR k = 1 TO 32000
FOR l = 1 TO 2
nums(k, l) = 0
NEXT l
NEXT k
BLOAD "star52a.sav" ' Uses segment, offset recorded
BLOAD "star52b.sav" ' in the BSAVEd file.
PRINT nums(200, 2); " is 200+2"
PRINT nums(25000, 1); " is 25000+1"