Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]

Variables


Variables are named repositories where information is stored. A variable can have virtually any size and can contain any of the IDL data types. Variables can be used to store images, spectra, single quantities, names, tables, etc.

Attributes of Variables

Every variable has a number of attributes that can change during the execution of a program or terminal session. Variables have both a structure and a type.

Structure

A variable can contain a single value (a scalar) or a number of values of the same type (an array) or data entities of potentially differing type and size (a structure). Strings are considered as single values, and a string array contains a number of variable-length strings.

In addition, a variable can associate an array structure with a file; these variables are called associated variables. Referencing an associated variable causes data to be read from, or written to, the file. Associated variables are described in ASSOC.

Type

A variable can have one and only one of the following types: undefined, byte, integer, unsigned integer, 32-bit longword, unsigned 32-bit longword, 64-bit integer, unsigned 64-bit integer, floating-point, double-precision floating-point, complex floating-point, double-precision complex floating-point, string, structure, pointer, or object reference.

When a variable appears on the left-hand side of an assignment statement, its attributes are copied from those of the expression on the right-hand side. For example, the statement

ABC = DEF 

redefines or initializes the variable ABC with the attributes and value of variable DEF. Attributes previously assigned to the variable are destroyed. Initially, every variable has the single attribute of undefined. Attempts to use the value of an undefined variables result in an error.

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
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

Warning
A variable cannot have the same name as a function (either built-in or user-defined) or a reserved word (see the following list). Giving a variable such a name results in a syntax error or in "hiding" the variable.

The following table lists all of the reserved words in IDL.

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


Home | Categories | Alphabetical | Classes | All Contents | [ < ] | [ > ]