In every project there are gotchas, little unforseen issues that must be worked through as you migrate from development to production. In a previous post I brought up transitioning a Model-Glue: Unity application from a Windows development platform to a Linux platform while using two slightly different versions of MySQL. That would be one example.

Another recent project serves as a case in point as well, creating compliant header/nav/footer includes to be used site wide for a small site. Easy work, three or four files, including the stylesheets, with some example usage templates thrown in and a lot of comments for the developers who would use it. Oh yeah, did I mention it had to work on ColdFusion 5?

The core ColdFusion programming language hasn't truly changed a lot in the past six years. CFIF, CFOUTPUT, and CFLOOP are all pretty much the same, but it's still good to have an environment to test in that is the same as your production environment. Little did I know that Adobe had stopped permitting the download for the CF5 development server.

Luckily we have an outstanding development community for ColdFusion. After putting out the question to the House Of Fusion CF-Talk development list, I received several offers to help me test my code. I'm glad I did. It's been a long time since I've worked with a CF5 environment, and the little things will always get you. Like slight differences in stucture handling. Yes, most structure functions are still the same, but trying to build a structure object in CF5 is only possible once it's been implicitly created (i.e.: variables.myStruct = structnew()), otherwise dot notation assignment will error.

Another gotcha with CF5 would be scoped variables. In MX+, all scopes are accessible as structure objects, and can be read/manipulated using dot notation. Within CF5 all structures were not accessible as structure objects, for instance the variables scope. To have a structure that is accessible within the variables scope you would first have to implicitly declare it (as mentioned above).

view plain print about
2        variables.pageDefaults = structnew();
3        variables.pageDefaults.pageTitle = "Home";
4        variables.pageDefaults.additionalStylesheet = "home.css";
5        variables.pageDefaults.additionalScripts = "formValidation.js";
6        variables.pageDefaults.standardNavigation = 0;

After defining your structure in this manner you would be able to do basic existence checking within your code:

view plain print about
1<cfif structkeyexists(variables.pageDefaults,"pageTitle")>
2        <title>#variables.pageDefaults.pageTitle#</title>
3    <cfelse>
4        <title>Some Title</title>
5    </cfif>
If you had ommitted explicitly declaring variables.pageDefaults through the structnew() method then the following code would have worked within MX+, but errored out on CF5.

The moral to this story? There isn't one. Just one more tiny nugget to throw out there into the blogosphere, on the off chance that someone else can use it.