The miscellaneous ramblings and thoughts of Dan G. Switzer, II

ColdFusion TechNote: Recommended supported configurations for ColdFusion MX 6.1 and 7.0 Server

Adobe has released a new TechNote regarding Recommended supported configurations for ColdFusion MX 6.1 and 7.0 Server. This is probably a good document to have handy whenever you set up a clean install of ColdFusion. Hopefully they'll continue to modify this document as patches/upgrades are released.

Calculating the visual length of a string

Sorry I haven't blogged in a while, but I've been very busy working on a project. Part of the project requires that I convert HTML to formatted plain text. On the very surface, this may seem simple (just use a RegEx to remove the HTML,) but the key word in that first sentence was "formatted."

One of the many issues I've run into, is that none of the built-in ColdFusion string manipulation functions account for the "visual" length of a string. Since one of the things I needed to do was wrap text after XX number of visual characters; I needed a function that, unlike the standard len() function, would return the length of a string as it would appear on the screen. This means I have to take into account how many "spaces" a tab would occupy on the screen.

My first attempt was simply to count every tab character (chr(9)) as 8 spaces. While this number assured I would never go past the right edge of the content, it wasn't very accurate (as a tab can very between 1 space to 8 spaces in Windows.) I quickly started running into problems when I realized that for some functionality (like centering text,) I'd really need an accurate account of the total number of visual spaces a string was occupying.


Using CF to automatically pass form fields from page to page

I'm working on a project that requires state to be passed via form fields (i.e. a multi-step wizard.) This means that I end up needing to pass hidden form fields from page to page. This normally requires a funky series of if/elses to determine which values to include on each form. Also, as things change from one form to another, you'd need to update each page in the process to include the hidden form field required, otherwise the value gets lost.

Anyway, I started thinking it would be nice if I didn't have to write any if/else statements and just have the necessary fields required automatically passed. Well, if you're thinking "Why not just loop over the form scope?" Well, that's only part of the solution. You really need to exclude fields that are already on the page.

Fortunately, several years ago I had written some code that was part of a much bigger project, that could parse a string and find form fields and extra information about about the fields. Harvesting the code I had already written, I was able to whip out a tag that would parse the content between the start/end tags, look for any form fields in the content and exclude those fields from being copied as hidden form fields.