Symbolic Representation of Data

Numerical or string information can be given names. This is useful because names are sometimes easier to remember and the names can be used as variables in expressions. A name can be given to data in several ways, one of which is the assignment statement.

The assignment statement has the form Variable = Expression. The left side of = is the name that you want to give to the data. This is called a variable because its value can be changed with another assignment statement. The right side of = is an expression that determines the value that is represented by the variable after the expression has been evaluated.
 

Examples

Assignment Expression Comment
A = 3 Assign the integer value 3 to the variable A.
B = -1 Assign the integer value -1 to the variable B.
C = "My dog has fleas" Assign the string My dog has fleas to the variable C.
D=A+B+5 D has the integer value 7 after the expression has been evaluated.
 

Variable Names

IDL variables are named by identifiers. Each identifier must begin with a letter and can contain from 1 to 128 characters. The second and subsequent characters can be letters, digits, the underscore character, or the dollar sign. A variable name cannot contain embedded spaces, because spaces are considered to be delimiters. Characters after the first 128 are ignored. Names are case insensitive. Lowercase letters are converted to uppercase; so the variable name abc is equivalent to the name ABC. The following table illustrates some acceptable and unacceptable variable names.

Unacceptable and Acceptable IDL Variable Names.
Unacceptable Reason Acceptable
EOF  Conflicts with function name A
6A  Does not start with letter  A6
_INIT  Does not start with letter  INIT_STATE
AB@  Illegal character  ABC$DEF
ab cd  Embedded space  My_variable
Caution A variable cannot have the same name as a function (either built-in or user defined) or a reserved word (see the list below). Giving a variable such a name results in a syntax error or in "hiding" the variable.

Complete list of IDL Reserved Words
AND BEGIN CASE COMMON
DO ELSE END ENDCASE
ENDELSE ENDFOR ENDIF ENDREP
ENDWHILE EQ FOR FUNCTION
GE GOTO GT IF
LE LT MOD NE
NOT OF ON_IOERROR OR
PRO REPEAT THEN UNTIL
WHILE XOR