home *** CD-ROM | disk | FTP | other *** search
- <CFINCLUDE TEMPLATE="Check_IP.cfm">
-
- <CFIF ParameterExists(SaveFile) IS "Yes">
- <CFFILE ACTION="WRITE"
- OUTPUT="#StripCR(Form.Expressions)#"
- FILE="#ExpandPath('.\')#document.exp"
- >
- <CFLOCATION URL="expressions.cfm">
- </CFIF>
-
- <CFIF ParameterExists(OpenFile) IS "Yes"><CFLOCATION URL="OpenFile.cfm"></CFIF>
-
- <HTML>
- <HEAD>
- <TITLE>Expression Calculator</TITLE>
- </HEAD>
- <BODY BGCOLOR="#ffffff">
- <A HREF="help.htm"><IMG SRC="ExpressionEvaluator.gif" BORDER=0></A><BR>
-
- <CFIF ParameterExists(EmailFile) IS "Yes">
- <FORM ACTION="SendMail.CFM" METHOD=POST>
- <TABLE WIDTH=500>
- <TR><TD COLSPAN=2>
- <FONT SIZE=+1>E-MAIL YOUR EXPRESSIONS</FONT>
- <P><FONT SIZE=-1>You can use this page to e-mail the contents
- of the expression evaluator window. This may useful when reporting
- problematic behavior to Allaire, or simply when having a need to
- forward some of the expressions you tested to somebody seeking the
- correct syntax.</FONT>
- </TD></TR>
- <TR><TD>FROM: </TD><TD><INPUT TYPE="text" NAME="MailFrom" SIZE=53></TD></TR>
- <TR><TD>TO: </TD><TD><INPUT TYPE="text" NAME="MailTo" SIZE=53 VALUE="support@allaire.com"></TD></TR>
- <TR><TD>SUBJECT:</TD><TD><INPUT TYPE="text" NAME="Subject" SIZE=53 VALUE="CF Expression Evaluator Content"></TD></TR>
- <TR><TD COLSPAN=2> <TEXTAREA NAME="MailMessage" COLS=58 ROWS=10>
- <CFOUTPUT>#FORM.Expressions#</CFOUTPUT></TEXTAREA></TD></TR>
- <TR><TD COLSPAN=2 ALIGN=right><INPUT TYPE="button" NAME="CancelMail" VALUE="Cancel" OnClick="history.go(-1)">
- <INPUT TYPE="submit" VALUE="Send Mail"></TD></TR>
- </TABLE>
- </FORM>
- <CFABORT>
- </CFIF>
-
- <!--- Initialize variables used by the evaluator --->
-
- <cfset LineNum = 0>
- <cfset CRLF = Chr(13) & Chr(10)>
- <cfset ExprList = Form.Expressions>
-
- <!--- Loop over the each expression --->
-
- <cfloop index="ExprElem" list=#ExprList# delimiters=#CRLF#>
-
- <!--- Clean up whitespace from the front of the expression--->
- <cfset ExprElem = LTrim(ExprElem)>
-
- <!--- Process only if the expression element is not a comment --->
- <cfif Left(ExprElem, 2) neq "//">
-
- <!--- Parse the expression from the variable it is assigned to (if any).
- If there is no assignment, use a temporary variable --->
-
- <cfset EQIndex = Find("=", ExprElem)>
- <cfif EQIndex neq 0>
-
- <cfset VarName = RTrim(Left(ExprElem, EQIndex - 1))>
- <cfset Expr = Mid(ExprElem, EQIndex + 1, 10000000)>
-
- <cfelse>
-
- <cfset VarName = "TempVar">
- <cfset Expr = ExprElem>
-
- </cfif>
-
- <!--- Evaluate the expression --->
- <cfset ExprVal = Evaluate(Expr)>
-
- <!--- Assign the result to the assignment variable --->
- <cfset TempVar = SetVariable(VarName, ExprVal)>
-
- <!--- Determine what to output --->
- <cfif IsSimpleValue(ExprVal)>
- <cfset ExprText = ExprVal>
- <cfelseif IsQuery(ExprVal)>
- <cfset ExprText = "A query with columns (#ExprVal.ColumnList#) and #ExprVal.RecordCount# rows">
- <cfelseif IsArray(ExprVal)>
- <cfset ExprText = "A an array whose first dimension is of size #ArrayLen(ExprVal)#">
- <cfelse>
- <cfset ExprText = "An object">
- </cfif>
-
- <!--- Output result --->
- <cfset LineNum = LineNum + 1>
-
- <cfoutput><PRE>
- <B>Line #NumberFormat(LineNum, "099")#:</B> #ExprElem#
- <B> Result:</B> #ExprText#<P></PRE>
- </cfoutput>
- <CFELSE>
- <CFOUTPUT>
- <I><FONT SIZE=-1 FACE="Courier New" COLOR="##008000">#ExprElem#</FONT><I><BR>
- </CFOUTPUT>
- </cfif>
-
- </cfloop>
-
- </BODY>
- </HTML>
-