Previous ION Script User's Guide: ION Script Tag Reference Next

VARIABLE_DECL

The VARIABLE_DECL tag is used to declare a new variable in an ION Script application. The value for a variable can come from another variable, a numeric value, or an expression.

If the value you assign to a variable is an undefined variable or any expression that cannot be evaluated, the resulting value of the variable depends on the TYPE it was assigned. If TYPE is "INT" or "DOUBLE," the result is 0. If TYPE is "BOOL," the result is false. If TYPE is "STR," the result is a null string.


Note
The VARIABLE_DECL tag must reside between the <VARIABLES> and </VARIABLES> tags.

Syntax

<VARIABLE_DECL
NAME="name"
TYPE={"BOOL" | "INT" | "DOUBLE" | "STR"}
VALUE="expression"
[PERSIST={"TRUE" | "FALSE"}] />

Attributes

NAME

Defines the name of the variable. Do not precede the variable name with the $ symbol. This attribute is required. See Variables, Expressions & Operators for information on variable names.

PERSIST

Set this attribute to TRUE to make the variable persistent. Persistent variables are used to maintain application state from one ION Script page to another. Once a variable is declared with PERSIST set to TRUE, it is available to all ION Script pages that are called without having to re-declare the variable in each page. If PERSIST is set to FALSE, the variable can only be referenced in the page in which it is declared.

TYPE

Defines the variable's data type. This attribute is required. The following table lists the allowable values for the TYPE attribute:

Table 5-12: TYPE Attributes 

Table 5-12: TYPE Attributes 
Attribute Value
Data Type
BOOL
Boolean
INT
Integer
DOUBLE
Double precision
STR
String

See Variables for more on variable types.

VALUE

Defines the initial value of the variable. This attribute is required, and can contain a variable. If the type of data specified for VALUE differs from the specified TYPE, the value will be changed to the type specified by the TYPE attribute. See Variable Types for a list of the cases in which the value is converted.

When setting the VALUE attribute to a string literal, the string should be enclosed in single quotation marks, all inside the double quotation marks that delimit the attribute value. For example, the following code shows the correct way to assign a string literal to the VALUE attribute:

<VARIABLE_DECL NAME="animal" TYPE="STR" VALUE="'dog'"/>  

If you are assigning the VALUE attribute a string variable as opposed to a string literal, do not enclose the variable in single quotation marks. For example, if the variable animal has already been defined as a string, you would assign the value of the animal variable to a new variable as follows:

<VARIABLE_DECL NAME="pet" TYPE="STR" VALUE="$animal"/>  

 


Warning
Assigning $Browser.REMOTE_USER as a string variable to the VALUE attribute can be dangerous because it is frequently an undefined system variable. When VALUE is undefined, IDL reports an error. However, it is possible that code that uses $Browser.REMOTE_USER could be implemented and tested without error on one system and fail if ported to another system.

HTML Mapping

The VARIABLE_DECL tag is not converted to HTML, and therefore does not accept any other attributes.

  IDL Online Help (March 06, 2007)