You can't test for an explicit NULL in ColdFusion.

If a ColdFusion variable exists it will have a value. The closest you'll get to a NULL is an empty string.

With that in mind, you can test to see whether a variable is defined or not using isDefined().

<cfif isDefined('myvar')>

</cfif>

Note the quotes around the variable name that is being tested.

You can test whether a variable has a value in a number of ways depending on the variable in question, but quite often you will want to test to see if it has any length:

<cfif len(myvar)>

</cfif>

You may also want to do additional checks on variables such as boolean URL variables:

<cfif isDefined('url.logout') AND isBoolean(url.logout) AND url.logout>
   <!--- Your logout code goes here --->
</cfif>

Spike

Andrew Dickinson wrote:

I don't think I covered this question last time I asked about Is Null.

How can I express a command like

<CFIF Var IS NULL>

?

This syntax is allowed inside SQL, but I need to do this or something like
it in CF. I'm still playing around with the results of left/right joins.


And while I'm at it, will someone please tell me how to search/access the CFAussie archives ? I've had several goes at it, and never managed a non-nil result.

---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/





-- Stephen Milligan Consultant for hire http://www.spike.org.uk



---
You are currently subscribed to cfaussie as: [EMAIL PROTECTED]
To unsubscribe send a blank email to [EMAIL PROTECTED]

MX Downunder AsiaPac DevCon - http://mxdu.com/

Reply via email to