Microsoft KB Archive/61349

= Basic PDS 7.00 &quot;Program Memory Overflow&quot; with Too Many CONST =

Article ID: 61349

Article Last Modified on 11/21/2006



This article was previously published under Q61349



SUMMARY
When used with the /V switch, the BC.EXE compiler that comes with Microsoft Basic Professional Development System (PDS) version 7.00 produces a &quot;Program memory overflow&quot; error when compiling a program that has approximately 680+ CONSTants. The compiler can still have up to 13K &quot;bytes free&quot; of compiler workspace when reporting this error.

&quot;Program memory overflow&quot; also occurs when compiling the TEST1.BAS program generated below using 756+ CONSTants with the BC /Fs (far strings) option.

The CONST limits are improved in Basic PDS version 7.10, which can handle significantly more CONSTants than Basic 7.00.

The error message &quot;Program memory overflow&quot; is misleading because normally the compiler only gives that error when more than 64K of code has been generated for the module being compiled. This error represents a limitation of the compiler. This error is generated when the number of CONSTants that can be included in a Basic module has been exceeded.



MORE INFORMATION
The &quot;Program memory overflow&quot; error above is due to the amount of internal overhead that the compiler sets aside to do its work with CONSTants. The error message is not generated because of a lack of compiler workspace. In this case, 13K &quot;bytes free&quot; is a valid number. There is actually 13K of compiler workspace free. A different limitation has been encountered -- the number of CONSTants BC.EXE can handle.

The BC.EXE in QuickBasic version 4.50 and the BC.EXE compiler in Basic versions 6.00b and 7.10 will successfully compile a program with over 1000 CONSTants.

Illustration
To demonstrate the limitation in 7.00, use the FIRST.BAS program below to create the Basic program TEST1.BAS with &quot;n&quot; number of CONSTants. For example, a TEST1.BAS program created with approximately 650 CONSTants will compile with no errors in Basic PDS 7.00. A program with 680+ CONSTants compiled with BC /V gives &quot;Program-memory overflow&quot; in Basic PDS 7.00.

As a comparison to versions earlier than 7.00, if you create a TEST1.BAS program with 1000 CONSTants, it will compile correctly with BC.EXE 4.50 and BC.EXE 6.00b (which have a greater capacity for CONSTants than 7.00).

As a comparison to 7.10, in TEST1.BAS created below, 7.10 can handle 1100 CONSTants when compiled BC /V (but 1200 CONSTants gives &quot;Program memory overflow&quot;). In TEST1.BAS created below, 7.10 can handle 2100 CONSTants when compiled BC /Fs (but 2200 CONSTants gives &quot;Compiler out of memory, 0 bytes free&quot;). Basic 7.10 can thus handle many more CONSTants than 7.00.

FIRST.BAS
FIRST.BAS prompts you for a number, and then creates another Basic program, TEST1.BAS, with that many CONSTants. Compile the resulting TEST1.BAS with BC /V or /Fs to test for compiler limitations. DEFINT A-Z CLS INPUT &quot;How many CONSTants to you want in the file: &quot;, Num% OPEN &quot;test1.bas&quot; FOR OUTPUT AS #1 beg$ = &quot;CONST p&quot; equals$ = &quot; =&quot; FOR i = 1 TO Num% constant$ = beg$ + LTRIM$(RTRIM$(STR$(i))) + equals$ + STR$(i) PRINT #1, constant$ NEXT CLOSE PRINT &quot;File 'test.bas' successfully created&quot; END

Additional query words: BasicCom

Keywords: KB61349

-

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

© Microsoft Corporation. All rights reserved.