ION Script source code:




<!-- Copyright (c) 1997-2002, Research Systems, Inc.  All rights reserved.
     Unauthorized reproduction prohibited. -->

<!-- This example titled "Passing IDL Variables to ION Script" demonstrates two advanced topics:
1.) How to get an IDL variable into an ION script variable using the ION_INCLUDE tag (limited to scalars).
2.) How to use the ION system variable $ION.uniqueID to name temporary files so that clients' files are handled without collision. -->

<ION_SCRIPT>
<ION_HEADER>
  <APPLICATION>ION Script Examples</APPLICATION>
  <TITLE>Passing IDL Variables to ION Script</TITLE>
  <AUTHOR>Research Systems, Inc.</AUTHOR>

  <VARIABLES>
    <VARIABLE_DECL NAME="TEMPFILE" VALUE="''" TYPE="STR" PERSIST="TRUE" />
    <VARIABLE_DECL NAME="MYVALUE" VALUE="0.0" TYPE="DOUBLE" PERSIST="TRUE" />
  </VARIABLES>
</ION_HEADER>

<ION_BODY>


This example demonstrates the technique for passing IDL variables to ION Script.<BR><BR>
We start with an ION Script variable with a value of zero:<BR><BR>
<TABLE BORDER="1" CELLPADDING="5">
  <TR><TD WIDTH="300">
    Starting ION Script variable value is: 
    <ION_VARIABLE NAME="$MYVALUE"/>.
  </TD></TR>
</TABLE><BR>
Next, we create an IDL variable in an ION_DATA_OUT tag: 
<!--Write a temporary file.  Use $ION.uniqueID to name the temp file.-->
<ION_EVALUATE EXPR="$TEMPFILE = $ION.temp + 'val' + $ION.uniqueID + '.ion'"/>
<ION_DATA_OUT DEBUG="FALSE">
    <IDL>
generatefile,'$TEMPFILE'
    </IDL>
</ION_DATA_OUT>
In our IDL code, we also dynamically create a temporary ION Script file. In it, we use the ION_EVALUATE tag to assign our ION Script variable with the value of our IDL variable.<BR><BR>
Next, we use the ION_INCLUDE tag to include the dynamically generated ION Script file in the page.<BR> 
<ION_INCLUDE SRC="ion:///$TEMPFILE" PRE="FALSE"/>
<BR><TABLE BORDER="1" CELLPADDING="5">
  <TR><TD WIDTH="300">
    Ending ION Script variable value is: 
    <ION_VARIABLE FORMAT="%14.7f" NAME="$MYVALUE"/>.
  </TD></TR>
</TABLE><BR>
Presto! The value of our ION Script variable is now equal to the value of our IDL variable.  
</ION_BODY>
</ION_SCRIPT>