Using RepeatString to create a mask in NumberFormat

{ Posted By : Eric Cobb on September 2, 2010 }
58 Views
Related Categories: CFML

Today I was working on creating a CSV file that required numeric columns to be a fixed number of digits, using leading zeros to make up the difference. So, for example, if the column required 5 digits, the number 123 should show up as 00123. This is super simple using the NumberFormat() function in CFML, simply specify a mask like so:

<cfset variables.myNum = NumberFormat(123,'00000')>
<cfoutput>#variables.myNum#</cfoutput>

But, in my particular case, I had several columns that required 12 and 15 digit numbers.

More »

Accessing Application.cfc methods from Application.cfm

{ Posted By : Eric Cobb on March 30, 2010 }
1150 Views
Related Categories: CFML

This is pretty cool. I really had no idea that you could do this. (Now why you would want to do this is another story!)

As I mentioned in my last post, I've been spending a lot of time lately working on porting a legacy ColdFusion application over to Application.cfc. Everything has been going pretty well, until I started getting into sub-directories that have their own Application.cfm files in them. There's not a whole lot going on in these Application.cfm files, but each one of them is required and each one of them has a different name in its cfapplication tag.

More »

Query struct gets added to the Variables scope of Application.cfc, whether you like it or not.

{ Posted By : Eric Cobb on March 29, 2010 }
894 Views
Related Categories: CFML, ColdFusion

I've been spending a lot of time lately working on porting a legacy ColdFusion application over from Application.cfm to Application.cfc on ColdFusion 8. One of the things I'm paying close attention to is what gets put into the variables scope inside of my Application.cfc. I don't want to accidentally have stuff floating around in there and causing problems. So, my constantly checking the variables scope of various methods is how I found this little gem.

Did you know that, even if a query name is var scoped in Application.cfc, you'll still get CFQUERY.EXECUTIONTIME stored in the variables scope of your CFC?

More »

Using a Java Object to replace blanks in a list.

{ Posted By : Eric Cobb on March 26, 2010 }
985 Views
Related Categories: Java, CFML

Today I was working on parsing through a CSV file, when I came across the all too familiar "ColdFusion ignores blank list elements" situation. This is nothing new, it has been around forever, and there's even an excellent udf on cflib that does a great job of handling this. But, I was feeling a little creative and decided to see if I could tap into Java and accomplish the same thing.

As it turns out, it was actually pretty easy to do.

More »

Using Java objects to loop through a directory and check date last modified on files.

{ Posted By : Eric Cobb on February 25, 2010 }
1055 Views
Related Categories: Java, CFML

This is probably a no-brainer for some of you, but I was playing around with CFML's underlying Java capabilities the other day and thought I would share this little gem. Not that it's all that extraordinary, or even really useful, I've just got some free time and I haven't blogged anything in a couple of weeks so I figured "why not?".

More »

Discrepancies in the way ColdFusion validates dates.

{ Posted By : Eric Cobb on February 8, 2010 }
912 Views
Related Categories: CFML, ColdFusion

There seems to be discrepancies in the various date validations used throughout ColdFusion, or at least I've found one case where it inconsistently considers a value a valid date. It's probably easier to demo what I'm talking about than to try to explain it. Here's an example:

More »

Problem with cfqueryparam and Oracle's char datatype.

{ Posted By : Eric Cobb on January 8, 2010 }
1190 Views
Related Categories: Databases, CFML

I ran into a problem this afternoon with cfqueryparam when querying an Oracle database that really had me scratching my head. In my query's WHERE clause I was filtering against a column that had a CHAR(8) datatype, but whenever I ran the query with cfqueryparam it wouldn't return any results.

More »

CFML 101 - Rookie Mistakes Part 2

{ Posted By : Eric Cobb on December 17, 2009 }
964 Views
Related Categories: CFML, CFML 101

Just as in Rookie Mistakes Part 1, this post will cover mistakes that we've all made at one point or another. These are things that seasoned developers instinctively know to do, but beginners may not realize are better or more efficient. Some of this post is based loosely on Adobe's Coding Best Practices for ColdFusion Performance, with a few of my own personal favorites thrown in there.

More »

A valid use for the Evaluate() Function?

{ Posted By : Eric Cobb on December 10, 2009 }
1013 Views
Related Categories: CFML

In the comments to my recent Rookie Mistakes post, Paul mentions that he is using Evaluate() to get the value of variables stored in a database. In this particular case, he's not storing the variable values in the DB, he's storing the actual variable names and then using Evaluate() to get their values via CF. To be specific he's storing a formula in the DB, and then using Evaluate() to perform the calculation and get the values.

More »

CFML 101 - Rookie Mistakes Part 1

{ Posted By : Eric Cobb on December 6, 2009 }
1412 Views
Related Categories: CFML, CFML 101

This is the first in what I hope to be a continuing series of CFML 101 articles. My intent is to produce a blog series aimed at the beginning CFML developer, one which helps to explain basic techniques and concepts to those new to the CF world. The topics and examples covered in this series focus on the CFML programming language in general, not a specific application server. So whether you're using ColdFusion, Railo, or Blue Dragon (referred to as CF/R/BD from this point forward) to run your CFML applications, these concepts still apply.

More »

More Entries »