Contents - Index



The $COMMON directive provides a means for passing information from the main program to internal functions, procedures, modules, and subprograms.  Use of $COMMON provides an alternative to passing values as arguments. This directive is similar in concept to the COMMON statement in FORTRAN.  It differs in that information flow is one-way.  Variable values can be passed from the main program to the function, procedure or module.  However, if the function, procedure or module changes the value of a variable in COMMON, the change will not be seen in the main program. 


The $COMMON statement must directly follow the C, PROCEDURE, MODULE, or SUBPROGRAM declaration on a line by itself.  Variables appearing in the $COMMON statement are separated with commas, as in the following example.



$COMMON B,C,D {­variables B,C, and D are from the main program}



B=4;  C=5;  D=6



$COMMON should only be used with Functions, Procedures, Modules, and Subprograms appearing in the Equations window.  It should not be used with library functions.  Note that Array Range Notation (e.g., X[1..5] can be used in the $COMMON directive.


Note the complex variables can be passed to a Subprogram that is operating in the complex mode with a $Common directive.