• Print

Author Topic: How to convert from multi-modular to a QB64 single module.  (Read 1811 times)

Pete

  • Hero Member
  • *****
  • Posts: 7249
  • Cuz I sez so varmint!
How to convert from multi-modular to a QB64 single module.
« on: December 10, 2009, 08:00:45 pm »
I just compiled a 312K program. It only took about 5-minutes this time. anyway, it started, but it is one that requires another program I have to call it; so I have to get busy and unmodularize that one next.

It takes about 90-minutes work to put the modules together and rem-out the statements still not supported.

The method using the QB IDE is:

Load all files...

Move all DECLARE statements to main module.

Move all DATA to the main module.

Move all Error handlers to the main module.

- Note: Error traps are remembered in a module. If you go to a different module, make a new ON ERROR statement, it will only be good for that module. Once the sub is exited and control is back to the previous module, the last ON ERROR statement in that module is again in effect. Since all error handlers are now in the same module, you may have to update them to allow for this change.

Convert all COMMON SHARED variables to DIM SHARED or REDIM SHARED in the main module.

- Note: If you use REDIM in a sub do not use REDIM SHARED, it is not allowed because the variable remains a shared once it is declared that way in the main.

- Note: You will need to REMOVE or type in the number of elements in each array in any COMMOM SHARED statement that appears as the following example: COMMON SHARD (x(), y(), z()). This would be converted to DIM SHARED (x(), y(), z()). Now you must either remove them and DIM them in a more appropriate place in your program or leave them and supply the number of elements to each, such as a DIM SHARED (x(100), y(20), z(300)). The same is true for multi-dimensional arrays.
Move all subs and functions to the main module.

-Note be careful about duplicate variable names. Although duplicate names represent completely different values when separated in modules, when you join the modules, you will encounter a problem. It is recommended to rename any duplicate named variables as well as rename any duplicate labels or line numbers between modules before joining them.

Remove all modules except main module.

Rem-out all unsupported statements.

Save new file.


-------------------------

I'll modify this post if I discover additional conversions.

>>> I posted a utility I created to help auto-convert multi-modular files:
http://www.qb64.net/forum/index.php?topic=533.0

Pete
« Last Edit: December 18, 2009, 12:42:57 pm by Pete »
Give a man a program, and he does one thing for a day. Teach a man to program, and he does one thing for a lifetime.

coma8coma1

  • Sr. Member
  • ****
  • Posts: 494
Re: How to convert from multi-modular to a QB64 single module.
« Reply #1 on: February 26, 2010, 05:28:55 am »
Quote from: Pete on December 10, 2009, 08:00:45 pm
...
Convert all COMMON SHARED variables to DIM SHARED or REDIM SHARED in the main module.
...

Pete


Thanks Pete, I found this thread very useful  ;)

  • Print