Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 480
Reno Avatar asked Oct 13 '11 17:10

Reno


People also ask

How do you check if a string is not null and not empty?

The isNotBlank() checks that the input parameter is: not Null, not the empty string ("") not a sequence of whitespace characters (" ")

How do you check if a number is not null?

Use the strict inequality (! ==) operator to check if a variable is not null, e.g. myVar !== null . The strict inequality operator will return true if the variable is not equal to null and false otherwise.

How do I check if a string is nil?

To check if a string is null or empty in Java, use the == operator.

How do you check if a value is empty or not?

You can use lodash: _. isEmpty(value).


1 Answers

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 >
like image 111
Peter Boughton Avatar answered Sep 22 '22 01:09

Peter Boughton