Passing DYNAMIC and STATIC Arrays in COMMON; Macintosh BASIC (32222)






This article was previously published under Q32222

SUMMARY

Passing STATIC and DYNAMIC arrays in COMMON differs for compiled and interpreted Macintosh QuickBASIC programs. The order in which arrays are declared in COMMON and dimensioned is crucial for the compiler. Because either of the compiler formats is acceptable under the interpreter, Microsoft recommends following the syntax rules for compiled programs, as shown in formats 1 and 2 below.

MORE INFORMATION

The formats for DYNAMIC and STATIC arrays in COMMON for the compiler and interpreter are as follows:

  1. The following information pertains to passing STATIC arrays in COMMON in a compiled program:

    The DIM STATIC statement (or the DIM statement when the "Use Static Arrays" option is on) must come before the COMMON declaration. The array name in the COMMON declaration must be followed by empty parentheses, as shown below:
             DIM STATIC A(20,20)
             COMMON A()
    						
  2. The following information pertains to passing DYNAMIC arrays in COMMON in a compiled program:

    The DIM statement must come after the COMMON declaration. The array name in the COMMON declaration must be followed by the number of dimensions (not the sizes of the dimensions) in parentheses as shown below:
             COMMON A(2)
             DIM A(20,20)
    						
  3. The following information pertains to passing DYNAMIC arrays in COMMON in an interpreted program:

    The COMMON declaration may come before or after the DIM statement in the interpreter. The array name in the COMMON declaration may be followed by the number of dimensions (not the sizes of the dimensions) in parentheses, or the array name may be followed by empty parentheses.
  4. The following information pertains to STATIC arrays in an interpreted program:

    There are no STATIC arrays in an interpreted program. Although you may use DIM STATIC in the interpreter, it allocates only DYNAMIC arrays. The STATIC keyword in a DIM statement is ignored by the interpreter. Because either of the compiler formats is accepted by the QuickBASIC interpreter, Microsoft recommends following the rules for compiled programs.

Modification Type: Minor Last Reviewed: 1/9/2003
Keywords: KB32222