home *** CD-ROM | disk | FTP | other *** search
/ Australian Personal Computer 1999 April / APC443.iso / features / grpware / coldfus / coldfusi.exe / data1.cab / Documentation / snippets / evaluate.cfm < prev    next >
Encoding:
Text File  |  1998-10-08  |  1.3 KB  |  70 lines

  1. <!--- This shows the use of DE and Evaluate --->
  2.  
  3. <HTML>
  4.  
  5. <HEAD>
  6.  
  7. <TITLE>
  8. Evaluate Example
  9. </TITLE>
  10.  
  11. </HEAD>
  12.  
  13. <BODY bgcolor=silver>
  14.  
  15. <H3>Evaluate Example</H3>
  16.  
  17.  
  18. <CFIF IsDefined("form.myExpression")>
  19. <H3>The Expression Result</H3>
  20.  
  21. <CFTRY>
  22. <!--- Evaluate the expression --->
  23. <CFSET myExpression = #Evaluate("#form.myExpression#")#>
  24.  
  25. <!--- Use DE to output the value of the variable, unevaluated --->
  26. <CFOUTPUT>
  27. <I>The value of the expression #Evaluate("#DE("#form.MyExpression#")#")#
  28. is #MyExpression#.</I>
  29. </CFOUTPUT>
  30.  
  31.  
  32. <!--- specify the type of error for which we are fishing --->
  33. <CFCATCH TYPE="Any">
  34. <!--- the message to display --->
  35.     <H3>Sorry, there's been an <B>Error</B>.
  36.     Try a simple expression, such as "2+2".</H3>
  37. <CFOUTPUT>
  38. <!--- and the diagnostic message from the Cold
  39. Fusion server --->
  40.     <P>#CFCATCH.message#
  41. </CFOUTPUT>
  42. </CFCATCH>
  43.  
  44. </CFTRY>
  45.  
  46.  
  47. </CFIF>
  48.  
  49. <H3>Simple Expression Evaluator</H3>
  50. <P>Input a simple expression (e.g., 2+2) or 
  51. A simple expression combined with CFML (e.g., 
  52. 32 MOD 9) and see the result, as well as the 
  53. name of the variable used to hold the information.
  54.  
  55.  
  56. <FORM ACTION="evaluate.cfm" METHOD="POST">
  57. <INPUT TYPE="Text" NAME="MyExpression" VALUE="2 + 2">
  58.  
  59. <INPUT TYPE="Submit" NAME="" VALUE="Evaluate my expression">
  60.  
  61.  
  62.  
  63.  
  64. </FORM>
  65.  
  66.  
  67. </BODY>
  68.  
  69. </HTML>       
  70.