trey,

this seems to be the most widely accepted way of doing that:

<!--- define the variable with an empty string to keep code from
breaking if it's not defined --->
<cfparam name="variable" type="whatever" default="">

<!--- check to see if the variable has a length. if yes, display
it --->
<cfif len(#variable#) >
    #variable#
</cfif>

oh, and, isdefined does *not* need to be locked. you only need to
lock variables scoped as application, session, and server.

~ dina



----- Original Message -----
From: "trey" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Monday, June 03, 2002 3:08 PM
Subject: if value exists, show it


> 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>
>
> or
>
> <cfif len(#variable#) GT 0>
> #variable#
> </cfif>
>
> or
>
> <cfif #variable# IS "">
> #variable#
> </cfif>
>
> Is one of these better than the others for dealing with text
values? I
> understand that IsDefined should be locked; I assume that is
not the case
> for the other two.
>
> TIA,
> Trey
>
>
>

______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to