coldfusioncoldfusion-8

Determining if a string is not null/blank and is a number and not 0?


I normally don't work in ColdFusion but there's a FTP process at work I have to create a report for with the only option right now being a ColdFusion 8 server. This FTP feed has a few issues (trash too).

So, I make the query and then I need to convert some of the string values during the output to do some math. Before that:

How do I tell if a field in the output loop: is not blank or null, is string that can be converted into a valid number, and is not 0?

Is there a simple way of doing this w/o a lot of if statements?

Thanks!


Solution

  • So you want to make sure that the variable is numeric but not zero?

    Then you want this:

    <cfif IsNumeric(MyVar) AND MyVar NEQ 0 >