Paul,

You're right you can use IsDefined in an IIf.  I do it all the time.  BTW
you should probably also trim the form.fieldname.

IE:

<Cfif IIF(IsDefined("form.fieldname"), "Trim(form.fieldname)", DE("")) is
"something">
The form fieldname equals something.
</cfif>

Bud,

>From the docs.

"The function evaluates its condition as a Boolean. If the result is TRUE,
it returns the value of Evaluate(string_expression1); otherwise, it returns
the value of Evaluate(string_expression2)."

The syntax is "IIf(condition, string_expression1, string_expression2)".

So in this case if the variable does in fact exist then it will evaluate
String1.  Otherwise it does string2.

HTH,
--K



-----Original Message-----
From: Paul Johnston [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 29, 2000 7:42 AM
To: [EMAIL PROTECTED]
Subject: RE: Can't work out IIF/IsDefined quirk


If I can't use IsDefined with IIF, how come the code I was given works then?
;)

As far as I am aware, IIF will work with any boolean expression, and
IsDefined is probably the most useful boolean function around in CF.

Paul

> -----Original Message-----
> From: Bud [mailto:[EMAIL PROTECTED]]
> Sent: 29 August 2000 15:26
> To: [EMAIL PROTECTED]
> Subject: RE: Can't work out IIF/IsDefined quirk
>
>
> On 8/29/00, Geoffrey V. Brown penned:
> >Hi,
> >Use this:
> >
> >#IIF(isdefined("form.categories"), "form.categories", de(''))#
>
> Sorry. You can't use isdefined in an IIF. If it's not defined it will
> still try and reference the variable and return an error. If you must
> use isdefined, you'll need to use a real cfif.
>
> What you can do is this:
>
> <CFIF isDefined('form.categories')>
> <cfset variables.categories = form.categories>
> <cfelse>
> <cfset variables.categories = "">
> </CFIF>
>
> IIf(variables.categories is "", DE(''), DE(variables.categories))#
>
> Or:
>
> IIf(variables.categories is "", DE(''), DE('#variables.categories#'))#
> --
>
> Bud Schneehagen - Tropical Web Creations
>
> _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
> ColdFusion Solutions / eCommerce Development
> [EMAIL PROTECTED]
> http://www.twcreations.com/
> 954.721.3452
> ------------------------------------------------------------------
> ------------
> Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
> To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.


----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to