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

ION_VARIABLE

The ION_VARIABLE tag is used to insert the value of an ION Script variable into the processed document.

Syntax

<ION_VARIABLE NAME="$variable" [FORMAT="format string"] />

Attributes

NAME

The name of the variable. Note that when referencing an ION Script variable, the variable name must be prefixed with the $ symbol.

FORMAT

Specifies the C-style printf() formatting string. The syntax for the FORMAT attribute is as follows:

FORMAT="%[flags][width][.precision][type length] specifier"

where

flags is one or more of the following characters:

Table 5-9: FORMAT Flags 

Table 5-9: FORMAT Flags 
Flag
Description
space
Precede the result with a space
-
Left-justify the result within the field if width is specified
+
Precede the result with a sign (+ or -). The default is to display only a minus sign.
#
  • If specifier is o, precede result with "0"
  •  

  • If specifier is x, precede result with "0x"
  •  

  • If specifier is X, precede result with "0X"
  •  

  • If specifier is e, E, f, g, G, the decimal point is always present in the result, even if no digits follow the decimal
  •  

  • If specifier is g, G, trailing zeros will display
0
Pad the result with leading zeros (if the specified width is greater than the width of the result).

width is an integer specifying the minimum field width. If the result has fewer characters than the field width, it is padded on the left (or right, if the - flag has been specified). The padding is done with spaces unless the first character of width is a zero, in which case the padding is done with zeros.

precision is an integer preceded by a decimal point specifying the minimum number of digits to appear for the d, o, or x format specifiers, or the maximum number of characters to be printed for the s format specifier. It is also the precise number of digits to display after the decimal (including trailing zeros) for the e, E, f, g, or G specifiers.

type length is one of the following:

Table 5-10: Type Length 

Table 5-10: Type Length 
Type Length
Description
h
For d, i, o, u, x or X specifiers: value is treated as a short or unsigned short.
l (lower case L)
The value is treated as a long or unsigned long
L
The value is treated as a long double

specifier is one of the following:

Table 5-11: ION Variable 

Table 5-11: ION Variable 
ION Variable Type
Valid Specifiers
BOOL, STRING
%s
INT
%d, %i, %o, %u, %x, %X
DOUBLE
%e, %E, %f, %g, %G


Note
For more information on using format specifiers, refer to a C programming manual.

HTML Mapping

The ION_VARIABLE tag is not converted to HTML, and therefore does not accept any other attributes. The value of the specified variable is inserted directly into the HTML stream.

Example

In the following example, we declare a variable, and then insert the value of the variable into the page. Note that in the variable declaration, we use only the variable name without the $ symbol, but when referencing the variable in the ION_VARIABLE tag, we precede the variable name with the $ symbol:

<ION_SCRIPT>  
<ION_HEADER>  
   <VARIABLES>  
      <VARIABLE_DECL NAME="foo" TYPE="INT" VALUE="5"/>  
   </VARIABLES>  
</ION_HEADER>  
<ION_BODY>  
   The value of foo is <ION_VARIABLE NAME="$foo"/>  
</ION_BODY>  
</ION_SCRIPT>  

The following text is written to the Web page:

The value of foo is 5

  IDL Online Help (March 06, 2007)