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

  1. <CFINCLUDE TEMPLATE="Check_IP.cfm">
  2.  
  3. <CFIF ParameterExists(SaveFile) IS "Yes">
  4.     <CFFILE ACTION="WRITE" 
  5.         OUTPUT="#StripCR(Form.Expressions)#" 
  6.         FILE="#ExpandPath('.\')#document.exp"
  7.         >
  8.     <CFLOCATION URL="expressions.cfm">
  9. </CFIF>
  10.  
  11. <CFIF ParameterExists(OpenFile) IS "Yes"><CFLOCATION URL="OpenFile.cfm"></CFIF>
  12.  
  13. <HTML>
  14. <HEAD>
  15. <TITLE>Expression Calculator</TITLE>
  16. </HEAD>
  17. <BODY BGCOLOR="#ffffff">
  18. <A HREF="help.htm"><IMG SRC="ExpressionEvaluator.gif" BORDER=0></A><BR>
  19.  
  20. <CFIF ParameterExists(EmailFile) IS "Yes">
  21.     <FORM ACTION="SendMail.CFM" METHOD=POST>
  22.     <TABLE WIDTH=500>
  23.     <TR><TD COLSPAN=2>
  24.     <FONT SIZE=+1>E-MAIL YOUR EXPRESSIONS</FONT>
  25.     <P><FONT SIZE=-1>You can use this page to e-mail the contents
  26.     of the expression evaluator window. This may useful when reporting
  27.     problematic behavior to Allaire, or simply when having a need to 
  28.     forward some of the expressions you tested to somebody seeking the
  29.     correct syntax.</FONT>
  30.     </TD></TR>
  31.     <TR><TD>FROM:    </TD><TD><INPUT TYPE="text" NAME="MailFrom" SIZE=53></TD></TR>
  32.     <TR><TD>TO:     </TD><TD><INPUT TYPE="text" NAME="MailTo" SIZE=53 VALUE="support@allaire.com"></TD></TR>
  33.     <TR><TD>SUBJECT:</TD><TD><INPUT TYPE="text" NAME="Subject" SIZE=53 VALUE="CF Expression Evaluator Content"></TD></TR>
  34.     <TR><TD COLSPAN=2>    <TEXTAREA NAME="MailMessage" COLS=58 ROWS=10>
  35. <CFOUTPUT>#FORM.Expressions#</CFOUTPUT></TEXTAREA></TD></TR>
  36.     <TR><TD COLSPAN=2 ALIGN=right><INPUT TYPE="button" NAME="CancelMail" VALUE="Cancel" OnClick="history.go(-1)">
  37.         <INPUT TYPE="submit" VALUE="Send Mail"></TD></TR>
  38.     </TABLE>
  39.     </FORM>
  40.     <CFABORT>
  41. </CFIF>
  42.  
  43. <!--- Initialize variables used by the evaluator --->
  44.  
  45. <cfset LineNum = 0>
  46. <cfset CRLF = Chr(13) & Chr(10)>
  47. <cfset ExprList = Form.Expressions>
  48.  
  49. <!--- Loop over the each expression --->
  50.  
  51. <cfloop index="ExprElem" list=#ExprList# delimiters=#CRLF#>
  52.     
  53.     <!--- Clean up whitespace from the front of the expression--->
  54.     <cfset ExprElem = LTrim(ExprElem)>
  55.     
  56.     <!--- Process only if the expression element is not a comment --->
  57.     <cfif Left(ExprElem, 2) neq "//">
  58.     
  59.         <!--- Parse the expression from the variable it is assigned to (if any). 
  60.               If there is no assignment, use a temporary variable --->
  61.               
  62.         <cfset EQIndex = Find("=", ExprElem)>
  63.         <cfif EQIndex neq 0>
  64.         
  65.             <cfset VarName = RTrim(Left(ExprElem, EQIndex - 1))>
  66.             <cfset Expr = Mid(ExprElem, EQIndex + 1, 10000000)>
  67.             
  68.         <cfelse>
  69.         
  70.             <cfset VarName = "TempVar">
  71.             <cfset Expr = ExprElem>
  72.  
  73.         </cfif>
  74.         
  75.         <!--- Evaluate the expression --->
  76.         <cfset ExprVal = Evaluate(Expr)>
  77.         
  78.         <!--- Assign the result to the assignment variable --->
  79.         <cfset TempVar = SetVariable(VarName, ExprVal)>
  80.         
  81.         <!--- Determine what to output --->
  82.         <cfif IsSimpleValue(ExprVal)>
  83.             <cfset ExprText = ExprVal>
  84.         <cfelseif IsQuery(ExprVal)>
  85.             <cfset ExprText = "A query with columns (#ExprVal.ColumnList#) and #ExprVal.RecordCount# rows">
  86.         <cfelseif IsArray(ExprVal)>
  87.             <cfset ExprText = "A an array whose first dimension is of size #ArrayLen(ExprVal)#">
  88.         <cfelse>
  89.             <cfset ExprText = "An object">
  90.         </cfif>
  91.         
  92.         <!--- Output result --->        
  93.         <cfset LineNum = LineNum + 1>
  94.         
  95.         <cfoutput><PRE>
  96. <B>Line #NumberFormat(LineNum, "099")#:</B> #ExprElem#
  97. <B>  Result:</B> #ExprText#<P></PRE>
  98.         </cfoutput>
  99.     <CFELSE>
  100.         <CFOUTPUT>
  101.             <I><FONT SIZE=-1 FACE="Courier New" COLOR="##008000">#ExprElem#</FONT><I><BR>
  102.         </CFOUTPUT>                
  103.     </cfif>
  104.     
  105. </cfloop>
  106.  
  107. </BODY>
  108. </HTML>
  109.