Interactive Data Language (IDL)
Global Variables in IDL: Common Blocks
Global variables are useful when it is not convenient to pass a variable from one function or procedure to another as an argument. In IDL, common blocks are used to declare global variables. The syntax is as follows:
"block_name" is the name of the common block, and var_1, var_2 and so on can be any type of variable. The COMMON keyword must appear in every function or procedure where the variable(s) in question are needed. If a function or procedure using global variables is compiled after one where the common block is defined, a common block reference statement can be used:
Following the commom block definition or reference statement, the global variables can be used like normal variables. In different functions or procedures one can use different names for the global variables by changing the variables' names in the common block definition statement. For more information on common blocks, please look up "common blocks" in the IDL Online Manual.
Return to IDL Resources >> Helpful Tips