[thelist] CFMX problem - HTML output cut off - and characterencoding

Judah McAuley judah at wiredotter.com
Wed Jul 16 16:23:15 CDT 2003

Steve Lewis wrote:
> While it does not generate parse or run-time errors, Jeff and I agree 
> that it is not our style.  It seems pretty obvious to me that cfset is 
> not the intended place for such expressions as 1+1 and for execution of 
> UDFs which do not return useful values.  The optimal place, in the eyes 
> of the language designers, was the cfscript tag.

It should be noted that that the language designers (or at least the 
language documentors) are pretty ambiguous.  Take a look at the 
Developing ColdFusion Applications book that comes with CF Studio 5.  In 
the section on Creating and Using Structures, you will see a great 
example of their ambiguity.  In an early section they provide the 
following syntax for inserting values from a form into a structure:

<cfset rc=StructInsert(employee, "firstname", "#FORM.firstname#")>
<cfset rc=StructInsert(employee, "lastname", "#FORM.lastname#")>
<cfset rc=StructInsert(employee, "email", "#FORM.email#")>
<cfset rc=StructInsert(employee, "phone", "#FORM.phone#")>
<cfset rc=StructInsert(employee, "department", "#FORM.department#")>

rc, in this example, is being used as a temp variable.  They could leave 
out the rc= and acheive exactly the same result, but they put in the rc= 
because cfset is "supposed" to be for assigning values.  Also note that 
they double quotes and pound signs around the form fields are entirely 
unnecessary and pretty ugly as well.

Later in the same section though they switch syntaxes completely and 
provide this example:

      StructInsert(employee, "firstname", "#FORM.firstname#");
      StructInsert(employee, "lastname", "#FORM.lastname#");
      StructInsert(employee, "email", "#FORM.email#");
      StructInsert(employee, "phone", "#FORM.phone#");
      StructInsert(employee, "department", "#FORM.department#");

This avoids the temp variable entirely by putting it in a cfscript 
block.  Do note that they still put the ugly double quote pound signs 
around the form variables though.

So it seems that Allaire/Macromedia is ambiguous around the intention of 
cfset.  I didn't find anywhere in the documentation (a very quick 
perusal at a few likely spots) that they left out the assignment 
altogether, but they certainly seem to be countenancing the use of 
throw-away assignments within cfsets.

For what it's worth, I favor the cfscript solution over the cfset 
whenever possible.


More information about the thelist mailing list