Skip to main content

2.2) Variable Names


You can name a variable nearly anything you like in IDL so it is a good idea to useful descriptives names for variables, rather than just a single letter. There are however some exceptions. The following list contains IDL "reserved words". Trying to name a variable using one of these words will cause a syntax error.

AND CONTINUE ENDFOR EQ GT NE
BEGIN DO ENDFOREACH FOR IF NOT
BREAK ELSE ENDIF FORWARD_FUNCTION INHERITS OF
CASE END ENDREP FUNCTION LE GOTO
COMMON ENDCASE ENDSWITCH GE LT OR
COMPILE_OPT ENDELSE ENDWHILE ON_IOERROR MOD PRO

You should also check the IDL help to make sure that the variable name that you are using isn't the same as an IDL built-in procedure or function as this will overwrite the function/procedure and you will be unable to use it for the remainder of the IDL session. One common example of this is to call your variable "mean", then every time you try to calculate the mean of something, you will just return your variable as the answer, each time.

The simplest way to check your variable name is not already used for an IDL function is to type "?" followed by the variable name at the IDL prompt. This will display the help page associated with that function if there is one.

? mean