sub programs and stuff

I'm currently developing a game in TB silver and there is a lot of code to it. Can someone please tell me how to divide it into separate smaller programs to make it easier to read. Thanks

Comments

Program units

Hi,

You can only split your "monster" program into smaller parts if you use sub-routines. Your main program should contain a series of lines of code. To reduce the program size you should split these lines into blocks, where each block carries out a particular task - about 20 lines is a good guide. Label each block with a sub-routine name, e.g.

SUB myroutine
REM: block of code
END SUB

Now create a completely new program (using any appropriate name you like such as "Myexternal" and type EXTERNAL on the first line. Now transfer the blocks of code (sub-routines) from your original program to this new external program. As you transfer each routine replace it with a CALL, e.g.

CALL myroutine

Add the keyword END to the external program.
In your original program, at the top add:

LIBRARY "Myexternal.trc"

Your original program will now consist almost entirely of a series of sub-routine CALLS and will be much much shorter.

This is very common practice. For example the TB editor contains more than ten thousand lines of code, but the main program unit only has a few hundred lines - the rest are contained in about a dozen external units.

Regards
Big John

thanks john, this really

thanks john, this really helped!