Important Notice
The pages on this site contain documentation for very old MS-DOS software,
purely for historical purposes.
If you're looking for up-to-date documentation, particularly for programming,
you should not rely on the information found here, as it will be woefully
out of date.
Keeping Variables Common
◄Contents► ◄Index► ◄Back►
──────────────────────────────────────────────────────────────────────────────
Keeping Variables Common
■ Variables may not be passed through COMMON if you move some of your SUB
procedures to another module. This is often caused by an improperly placed
or nonexistent COMMON SHARED statement in the second module. The various
combinations of COMMON, SHARED, and COMMON SHARED can be confusing.
■ One method that works correctly is to use COMMON statements throughout
your program. To simplify the use of COMMON statements, use the $INCLUDE
metacommand to group common definitions into an include file. In a larger
project, it is much easier to maintain a single file.
See: ◄$INCLUDE metacommand►
■ If you prefer using multiple COMMON statements:
• Insert a COMMON SHARED statement at the beginning of the main program.
For example:
COMMON SHARED A, B, C, D
• Insert a duplicate COMMON SHARED statement at the module level of all
other modules. Edit these modules by choosing Code from the View menu
(or press F2), then choose the name of the module you wish to edit.
See: ◄Scope Rules►