Hi Trey!

> I simply want to test to see if a variable has a value (eg text has been
> returned from a query) and if so, show it. There seem to be a few
options --
>
> <cfif isdefined(#variable#)>
> #variable#
> </cfif>

As Raymond already pointed out, isDefined() takes a string as the input and
returns a boolean that tells if the variable exists or not.  This will
return true even if the string is empty.  There is no locking required
specifically for isDefined().

> <cfif len(#variable#) GT 0>
> #variable#
> </cfif>

This assumes the variable exists and will output its contents if it is not
empty (sounds closest to what you want).  This could be better written
simply as..

<cfif len(variable)>

> <cfif #variable# IS "">
> #variable#
> </cfif>

This will not do much, since you're displaying the string if it IS empty.
If you changed the operator to IS NOT or NEQ it would act just like the
len() does above.  I would presonally prefer using len() in this case.

-Justin Scott, Lead Developer
 Sceiron Internet Services, Inc.
 http://www.sceiron.com


______________________________________________________________________
Your ad could be here. Monies from ads go to support these lists and provide more 
resources for the community. http://www.fusionauthority.com/ads.cfm
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to