What Are System Variables?
System variables are a special class of predefined variables available to all program units. Their names always begin with the exclamation mark character (!). System variables are used to set the options for plotting, to set various internal modes, to return error status, etc.
System variables have a predefined type and structure that cannot be changed. When an expression is stored into a system variable, it is converted to the variable type, if necessary and possible.
Changing the Value of a System Variable
Some system variables are read-only: they contain values that are static and cannot or should not be changed by the user. For example, the value of the system variable !PI always contains the single-precision value of pi (π), which is not available for redefinition.
You can change most system variables, however, simply by assigning a new value to the variable. For example, to change the current value of the !PROMPT system variable, which contains the text string used by IDL to prompt the user for input, simply assign a new string:
This change will persist for the duration of the IDL session or until you make a new assignment.
Some system variables take their values from a preference. Changing the value of the associated preference changes the value of the system variable (although in some cases the change will not take effect until IDL is restarted). Preference values persist between IDL sessions; your change will stay in effect until you either change the preference value or assign a new value to the system variable directly. For additional information on preferences, see IDL System Preferences.
Finally, you can define new system variables using the DEFSYSV procedure.
Default Values of System Variables
Each system variable takes its default value from one of the following sources:
- IDL's internal defaults. You cannot modify the default values of these system variables. The values of these system variables are either fixed (the value of !PI, for example) or must be generated by IDL depending on the current state (like the value of !ERROR_STATE).
- A user or system preference. You can modify the default values of these system variables by modifying the value of its associated preference. System variables with associated preferences are noted in the following sections.