|
ION Script User's Guide: ION Script Tag Reference |
|
The IDL tag pair delimits a block of IDL code. This tag pair must reside inside an ION_DATA_OUT or ION_IMAGE tag pair. Any valid IDL code is allowed between <IDL> and </IDL>, with the exception of the items listed below under IDL Tag Limitations.
<IDL>
[ION_EVALUATE or ION_VARIABLE tags]
IDL code (can contain $variable)
</IDL>
| Note The IDL tag pair must reside inside an ION_IMAGE or ION_DATA_OUT tag pair. |
None
The following IDL code cannot be used inside an <IDL>...</IDL> block:
object-graphics.ion in the examples directory.
.pro file. ION Script sends the commands in the <IDL> block to IDL one line at a time. Therefore, each line inside the <IDL> block must be a statement that is valid at the IDL command line. For example, you cannot use an <IDL> block as follows:<IDL> FOR X=1,20 DO BEGIN PRINT, X ENDFOR </IDL>
To perform the above statements, you would need to write a .pro file, and call the program from the <IDL> block.
When an IDL block is evaluated by the ION Script parser, the following sequence of events occurs:
The following example illustrates a case in which you might need to have the ION Script parser evaluate an ION_EVALUATE block before passing the data to IDL:
<ION_SCRIPT> <ION_HEADER> <VARIABLES> <VARIABLE_DECL NAME="A" VALUE="123" TYPE="INT"/> </VARIABLES> </ION_HEADER> <ION_BODY> <ION_DATA_OUT METHOD="GET"> <IDL> help, $A help, <ION_VARIABLE NAME="$A" FORMAT="%dL"/> </IDL> </ION_DATA_OUT> </ION_BODY> </ION_SCRIPT>
The FORMAT attribute causes the ION Script variable to be evaluated differently than if the variable were simply inserted into the IDL block. This page produces the following output:
INT = 123 LONG = 123
In IDL, strings can be enclosed in either single or double quotation marks. For example, both the following statements are valid:
print, "Hello World!" print, 'Hello World!'
Note, however, that double quotation marks have a special meaning when followed by a number. This syntax is used to denote an octal constant. Therefore, the following statement is not valid:
print, "1 Elm Street"
To avoid the syntax error caused by the above statement, you can enclose your string in single quotation marks:
print, '1 Elm Street'
Keep this in mind when using ION Script variables in an <IDL> block as well. For example, suppose you have defined the following ION Script variable:
<VARIABLE_DECL NAME="Address" VALUE="'1 Elm Street'" TYPE="STR" />
Assume you used the following code to print the value of this variable in an <IDL> block:
print, "$Address"
This code would be evaluated as
print, "1 Elm Street"
Because "1 has a special meaning in IDL, the above code would cause a syntax error. Instead, you would need to enclose the variable in single quotation marks as follows:
print, '$Address'
IDL code inside the <IDL>...</IDL> block can contain comments. IDL comments begin with the semicolon character (;). Everything after the ; character is ignored on that line. Comments can exist on their own line, or at the end of a line of code, as in the following example:
<IDL> ; This comment is on its own line A = 10 ; This comment is on the same line as a command </IDL>
| Note Comments cannot exist on a line that contains the line continuation character. See the following section. |
The $ symbol can have three different meanings when used in an IDL block:
If ION Script encounters a $ symbol in an IDL block, and the $ symbol is not preceded by the \ character, it will interpret whatever follows the $ symbol as an ION Script variable, unless the $ symbol is the last character on the line (including spaces). This allows you to use ION Script variables in your IDL code. The value of the ION Script variable will be substituted for the variable name before being passed to IDL.
When a line of IDL code extends beyond a certain length, it is often desirable to continue the code on the next line, thereby making your IDL code more readable. The IDL line continuation character indicates that the current statement is continued on the following line. The $ symbol must be the last character on the line for the line continuation to work. Comments (;) after the $ symbol will cause an error because the $ symbol is also used to denote an ION Script variable. Anything following the $ symbol in an ION Script page is considered a variable. The following example illustrates what is and what is not allowed when using the line continuation character:
<IDL> ; The following is a legal use of line continuation: A = 'This is ' + $ 'legal' print, A ; The following is *not* a legal use of line continuation ; because the $ character is not the last character: B = 'This is ' + $ ; Cannot put a comment here 'illegal' print, B C = 'This is also ' + $ 'legal' ; A comment is allowed here because the line ; does not contain a $ character print, C </IDL>
If you want a $ symbol to be interpreted by IDL as a $ symbol instead of a line continuation character, you must precede the $ symbol with a backslash, \. For example, if you want IDL to print the value of the variable cost, preceded by the $ symbol, you would use the following code: