[thelist] Problem with coldfusion and undefined vars

lordcutter at mac.com lordcutter at mac.com
Sun May 19 04:02:12 CDT 2002


Cool, it was the quotation marks - works fine now.

thanks,
Cameron

On Sunday, May 19, 2002, at 12:56 AM, Joshua Olson wrote:

> ----- Original Message -----
> From: "Cameron McCormick" <lordcutter at telocity.com>
> To: <thelist at lists.evolt.org>
> Sent: Sunday, May 19, 2002 12:45 AM
> Subject: [thelist] Problem with coldfusion and undefined vars
>
>
>> Hi,
>>
>> I have a problem where when I check for a var that may or may not be
>> set
>> it returns an error.
>>
>> I tried making a <cfif isdefined(varname)>something to do with
>> var</cfif> but it gives the same error that is isnt defined - why have
>> isdefined if it wont accept it?
>>
>> I am a newbie to CF, so any advice is appreciated.
>>
>> thanks,
>> Cameron
>
> With isdefined, make sure that you are passing the variable name as a
> string.  For example:
>
> <cfif isdefined("varname")>something</cfif>
>
> Make sure the string literal is actually the name of the variable.
>
> Some people prefer not to use isdefined at all.  Another approach is to
> use
> cfparam, such as this.
>
> <cfparam name="varname" default="some known value">
> <cfif varname IS "some known value">
>   do something
> </cfif>
>
> A downside to doing this is that CF must actually allocate memory for
> the
> variable even if you don't plan on using it.  Jeff will probably argue
> adamantly that IsDefined is pure evil for any number of reasons.  But,
> if
> IsDefined works for you, go with it.
>
> -joshua
>
>
> --
> For unsubscribe and other options, including
> the Tip Harvester and archive of thelist go to:
> http://lists.evolt.org Workers of the Web, evolt !
>




More information about the thelist mailing list