So a CFML variable name cannot end with a "." character

I spent a good hour today trying to get some old code working and got stuck trying to fix:

a CFML variable name cannot end with a "." character

Can you spot the issue in the following code block?

view plain print about
1<cffunction name="doLog" output="false" access="public" returntype="any">
2    <cfset var emailData = {} />
3    <cfset emailData.EmailAddressTo = variables.instance.config.getScheduledTaskEmailAddress() />
4    <cfset emailData.EmailSubject = "From the Nag Email Scheduled Task" />
5    <cfset emailData. EmailContent = "#arrayToList( variables._base._log, '#chr(13)##chr(10)#' )#" />
6    <cfset variables.instance.emailService.sendEmail( argumentcollection:emailData ) />        
7    <cfset super.doLog() />

The 5th line has an extra space in between the struct name and the key name. To me, the source of the error seems rather obvious now. It wasn't very obvious at all when I had to find this tiny space in several thousands of lines of code.

If you are curious to the manner in which I figured this out, I relied on an old standby, Divide and Conquer.

The Divide and Conquer method of debugging involves removing 50% of the source code (and still leaving a runnable application) then executing the process. Does the error remain? If so, put the removed code back, and chop out the other 50%.

Does the error still remain, if so, we'll label this chunk of code the Problem Set. Put 50% of the Problem Set code back and run the process again...

Wash. Rinse. Repeat.

This debugging technique is most useful when:

  • You are looking for syntax errors or CSS/HTML errors
  • When you have no context as to how the application works, or what it does
  • When you've been overanalyzing and underfixing

There are no comments for this entry.

Add Comment Subscribe to Comments

1/19/10 8:31 AM # Posted By phill.nacelli

Hey Dan,

Just curious, what does the robust exception show for file and line number where the error occurred?

1/19/10 8:39 AM # Posted By Dan Wilson


No ColdFusion error messages were being printed to the screen, I only had an entry in the ColdFusion debug exception section. I think this was because the error happened during the startup of a Model Glue ColdSpring application during the init and the errors are trapped there.

Actually, I'm not 100% sure why this was... but the message in the exception section pointed me to the creation of an object.. which in turn created other objects with complex initialization.


1/19/10 9:35 AM # Posted By M@

wouldn't it have been more natural to simply do
a find (using your text editor) on ". " and ".=" ?
excluding the quotation marks of cos.

1/19/10 2:40 PM # Posted By Steven Erat

Could be worse. Several versions ago, the code (notice the dot)
[CFPARAM default="" name="url."]
would produce this cryptic error message that some developer thought would be funny:

1/19/10 2:45 PM # Posted By Dan Wilson


I do recall that error and I always thought it to be funny. Sort of an easter egg...


In this case, your find would have worked, though there are plenty of cases where it would not have. Hindsight is a precious thing :)


1/19/10 6:51 PM # Posted By Leigh


If we were giving out grades for cryptic error messages, that one definitely deserves an "A" ;)

2/1/10 8:42 PM # Posted By Dennis

<cfset emailData. EmailContent

Effective use of syntax checking IDEs/editors can carry a great burden for you, even as an expert.

eclipse with cfeclipse over the top and error notification turned on can help catch some problems.

Using the free* compiler provided with coldfusion administrator can often give a quick response as to the location of your problem.

Invite a drive by coder/coworker over every time you spend more thna 15 minutes on an error. fresh eyes with diferent training might have spotted that sooner.


11/26/10 5:22 AM # Posted By Allan

what does the robust exception show for file and line number where the error occurred?

Add Comment Subscribe to Comments