Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

QBasic FAQ

How i modularize my program? by agual
Posted: 15 Feb 03

Symptom: You compile and have a PROGRAM MEMORY OVERFLOW error.

Your output code is probably bigger than 64K.
To make a bigger program you must split it in several modules(provided you are using SUBs and FUNCTIONS...).

-Remove some related subs and functions and put them in a second .bas file.
-Copy all the DECLARE lines from your main program to the top of the second file. You dont' really need them all but it will work.

-Convert all your DIM SHARED declarations to COMMON SHARED and copy them to the top of the second file.
-Add to your main module, after the COMMON SHAREDs DIM's (without SHARED) for all arrays you were dimensioning with DIM SHARED, as COMMON SHARED it's just a declaration and won't dimension anything.

-In case you were using SHARED in the subs and Functions instead of DIM SHARED in the main module you must create COMMON (not SHARED) declarations for all SHARED variables and put the m at the top of both modules. In this case you don't need to create a new DIM for arrays.

-Copy /move your TYPE declarations to the second file if there are variables of this type in the second file.

-Also copy all CONST definitions in the main part of your program to the top of the second file.

-Move each DATA line to the main part of the module if it will be READ from a SUB/function in the module.

This part must be done only once
-Enable Full Menus if you have them disabled
-Load both files in the IDE, one with Open Program and the other one with Load File.
-Then go to Run>Set Main Module and select your main program.
Next time you load your program QB will load all modules needed automatically

If i'm not forgetting nothing it should run and compile correctly....

NOTE1: If you gather all the duplicated  DECLARE SUB, DECLARE FUNCTION, COMMON SHARED, COMMON, CONST  and  TYPE  declarations in a separate file xxx.BI you can add '$INCLUDE 'xxx.bi' at the top of both modules and avoid having to maintain two sets of declarations.

NOTE2: Executable code at module level in modules different from main one will never execute.

Back to QBasic FAQ Index
Back to QBasic Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close