qck.hlp (Table of Contents; Topic list)
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.
Using Named COMMON
                                                 Contents  Index  Back
──────────────────────────────────────────────────────────────────────────────
 Using Named COMMON
 
 ■ A named COMMON block provides a convenient way to group variables so that
   different modules have access to only the common variables that they need.
 
 ■ Named COMMON blocks are not preserved across chained programs. Use blank
   COMMON blocks to pass variables to a chained program.
   See: Using COMMON with CHAIN
 
 ■ The following program fragment, which calculates the volume and density
   of a rectangular prism, uses named COMMON blocks to share different sets
   of data with two SUB procedures:
 
         DIM S(3)                      ' Main program
         COMMON /Sides/ S()
         COMMON /Weight/ C
         C=52
         S(1)=3:S(2)=3:S(3)=6
         CALL Volume
         CALL Density
         END
 
         DIM S(3)                      ' SUB procedure Volume in
         COMMON SHARED /Sides/ S()     ' a separate module
 
         SUB Volume STATIC
             Vol=S(1)*S(2)*S(3)
             .
             .
             .
         END SUB
 
         DIM S(3)                      ' SUB procedure Density in
         COMMON SHARED /Sides/ S()     ' a separate module
         COMMON SHARED /Weight/ W
 
         SUB Density STATIC
             Vol=S(1)*S(2)*S(3)
             Dens=W/Vol
             .
             .
             .
         END SUB
 
   The SUB procedure Volume shares only the variables representing the
   lengths of the sides (in COMMON block Sides). The SUB procedure Density
   also needs variables representing the weight (in COMMON block Weight).
   See: COMMON Statement  Scope Rules