Microsoft KB Archive/35149

= How to BSAVE and BLOAD Arrays Larger Than 64K =

Article ID: 35149

Article Last Modified on 8/16/2005

-

APPLIES TO


 * Microsoft Visual Basic for MS-DOS
 * Microsoft QuickBasic 4.0
 * Microsoft QuickBASIC 4.0b
 * Microsoft BASIC Compiler 6.0
 * Microsoft BASIC Compiler 6.0b
 * Microsoft BASIC Professional Development System 7.0

-



This article was previously published under Q35149



SUMMARY
Microsoft Visual Basic for MS-DOS, version 1.0 allows the use of &quot;huge&quot; 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 &quot;Path/File Access Error&quot; may result if those steps are omitted.

This information is also included with the Help file provided with the Standard and Professional Editions of Microsoft Visual Basic for MS-DOS, version 1.0.



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 &quot;star52a.sav&quot;, VARPTR(nums(1, 1)), 64000 DEF SEG = VARSEG(nums(16000, 1)) BSAVE &quot;star52b.sav&quot;, VARPTR(nums(16000, 1)), 64000 FOR k = 1 TO 32000 FOR l = 1 TO 2 nums(k, l) = 0 NEXT l NEXT k BLOAD &quot;star52a.sav&quot; 'Uses segment, offset recorded BLOAD &quot;star52b.sav&quot; 'in the BSAVEd file. PRINT nums(200, 2); &quot; is 200+2&quot; PRINT nums(25000, 1); &quot; is 25000+1&quot;

Additional query words: VBmsdos QuickBas BasicCom 4.00 4.00b 6.00 6.00b 7.00

Keywords: KB35149

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.