ION Script source code:




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

<!-- This guessing game example demonstrates four advanced topics:
1.) How to use the ION_IF, ION_ELSE, and ION_ELSEIF tags to check the values of ION variables.
2.) How to manually pass $Form variables to an ION page via a URL.
3.) How to get an IDL variable into an ION script variable using the ION_INCLUDE tag (limited to scalars).
4.) 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>ION Guessing Game Example</TITLE>
  <AUTHOR>Research Systems, Inc.</AUTHOR>

  <VARIABLES>
    <VARIABLE_DECL NAME="VALFILE" VALUE="''" TYPE="STR" PERSIST="TRUE" />
    <VARIABLE_DECL NAME="CURVALUE" VALUE="0" TYPE="INT" PERSIST="TRUE" />
  </VARIABLES>
  <EVENTS>
    <EVENT_DECL NAME="YESGAME" ACTION="ion:///YesGame.ion" />
    <EVENT_DECL NAME="NOGAME" ACTION="ion:///NoGame.ion" />
  </EVENTS>
</ION_HEADER>

<ION_BODY>


  <ION_IF EXPR="NOT ($Form.VALFILE ISTYPE 'UNDEF')">
    <ION_EVALUATE EXPR="$VALFILE = $Form.VALFILE"/>
  </ION_IF>

<!--Define the name and location of a temporary .ion file:-->
  <ION_IF EXPR="$VALFILE EQ ''">
    <ION_EVALUATE EXPR="$VALFILE = $ION.temp + '/val' + $ION.uniqueID + '.ion'" />
  </ION_IF>
<!--Use IDL random number generator to get the number and write the temporary file.
See the IDL source file "genvalue.pro"-->
  <ION_DATA_OUT DEBUG="FALSE">
    <IDL>
      genvalue,'$VALFILE'
    </IDL>
  </ION_DATA_OUT>

  <ION_FORM>
    <table cellspacing="1" cellpadding="3" border="1" bgcolor="#C0C0C0">
    <tr>
      <td>Would you like to play a game?</td>
      <td>
        <ION_BUTTON EVENT="YESGAME" TYPE="BUTTON" LABEL="Yes"/>
        <ION_BUTTON EVENT="NOGAME"  TYPE="BUTTON" LABEL="No"/>
      </td>
    </tr>
    </table>
  </ION_FORM>

</ION_BODY>
</ION_SCRIPT>