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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How i modularize my program?

How i modularize my program?

by  agual  Posted    (Edited  )
Symptom: You compile and have a PROGRAM MEMORY OVERFLOW error.

Solution:
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.

Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top