Coding for intranets (was RE: [thelist] Color Chooser Review -- c orrection)

nagrom morgan at morgankelsey.com
Wed May 29 09:53:01 CDT 2002


aardvark wrote:

> internal e-commerce testing application named MonkeyButler... i
> hooked it up so if it threw errors, it made a different monkey
> screech for each error... it also used non-standard HTML as part of
> the testing process (to make sure target application wouldn't poop
> the bed)...
>

and of course an option for monkey sign-language?
for those deaf monkey users?
<duck />



<tip type="ColdFusion Structure Bug>

If you're ever dynamically populating a coldfusion structure (say from a
database), watch out for database sytems that pad out fields with blank
spaces.
ColdFusion will allow you to declare a Key with spaces, though it shouldn't.

consider:

<cfscript>

colorList = "red,blue,red  ,green";
colors = StructNew();

 for (i=1; i LTE ListLen(colorList); i=i+1) {
  colors[ListGetAt(colorList,i)] = "yes";
  }

 for (item in colors) {
 WriteOutput(item & "<br />");
 }

</cfscript>

you should see two keys named 'red' !!!
which one are you referencing when you type:
colors.red
?!?!

the fix this, add the Trim() function to this line:
colors[Trim(ListGetAt(colorList,i))] = "yes";

now only one Key named 'red' will be created.

</tip>




More information about the thelist mailing list