Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Can compile some .BAS files but not others....

Status
Not open for further replies.

Sandmann

Programmer
Mar 12, 2001
13
US
I have QB4.5 and many programs I write can be compiled but others cannot. I have a game that I've made (that's about 200 KB) and the game works fine and runs (and is pretty cool) but when I try to compile, I get about 40 or 50 errors and just as many warnings. Does anyone have any idea why a working program wouldn't compile?
Thanks for any help.
 
Frequently, the interpreter makes up for little steps that the programmer has skipped -- for instance, not explicitly DIM'ing arrays -- but the compiler is not so lenient. Also, the IDE allocates static arrays from its heap at runtime, whereas the compiler pre-allocates the arrays inside the code segment (ie, reserves memory for them), so having more than 64k of static variables plus code in any function can run in the IDE, since the IDE basically treats all data chunks as dynamically allocated, but won't compile, since the compiler wants to keep any given subroutine inside of one segment. The solution is to make the compiler treat these variables as dynamic variables too. Careful, though; dynamic variables have a bit of a higher overhead than static variables, so you should take care to make as few variables dynamic as possible. To tell the compiler to treat all further variables that it encounters as dynamic, use the metadirective:
[tt]
'$DYNAMIC[/tt]

If you specify a DIM statement directly afterward, the corresponding variables & arrays will be allocated dynamically when the program is compiled. To specify that subsequent variables and arrays should be static, use the metacommand:
[tt]
'$STATIC[/tt]

For instance, to make just the array scrbuf&() dynamic, you could use the following sequence:
[tt]
'$DYNAMIC
DIM scrbuf&(16000)
'$STATIC
' rest of program here
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top