not that its much better than using IsDefined - but structkeyExists is
another alternative for the checkbox problem.
i prefer to use <cfparam name="mycheckbox " default="" >
<cfif mycheckbox neq "" > ...
but you can also do
<cfif structKeyExists(form,"mycheckbox") > ...
at least with this option you are only searching 1 scope rather than
all of them when using isDefined()
Pat
On Dec 8, 12:39 pm, "Andrew Scott" <[EMAIL PROTECTED]> wrote:
> Yes,
>
> I am well aware of your explanation, but let's look at something else for a
> minute.
>
> Forms?
>
> Now although cfparam can be used to handle radio buttons, you might need to
> do something like this
>
> <cfif IsDefined("form.radioButon")>
>
> . then do sql code
>
> </cfif>
>
> But if I do this
>
> <cfparam name="Form.RadioButton" default="Not Defined" />
>
> I still have to do
>
> <cfif Form.RadioButton neq "Not Defined">
>
> .. Then do sql code
>
> </cfif>
>
> And I am sorry, but I find the IsDefined() neater in that case:-)
>
> There are also other cases where I have used it too, but mainly with the
> form and URL scopes as far as variables go they are always declared with the
> var scope or variable scope.
>
> And yes I use MVC, its neater and cleaner in page design.
>
> Andrew Scott
> Senior Coldfusion Developer
> Aegeon Pty. Ltd.www.aegeon.com.au
> Phone: +613 8676 4223
> Mobile: 0404 998 273
>
> _____
>
> From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf
> Of Simon Haddon
> Sent: Friday, 8 December 2006 12:31 PM
> To: [email protected]
> Subject: [cfaussie] Re: Talking of evaluate()
>
> Hi,
>
> I think that your statement about using cfparam sums it up well. It is all
> about code design. If all you variables are declared and initialised at the
> beginning of a template, custom tag, function or cfc then it improves
> readability and maintainability. It helps to ensure that you have thought
> about each variable you are using and also, I find, that it reduces reuse of
> the same variable for cross purposes. Imagine if you have some code that
> uses isDefined and you are relying in the fact a variable exists to take
> some action. Then later some else comes along and uses the same variable
> name in another template. Woops. Code broken. If you "parametrise" and
> initialise your variables at the start of your template it is easier to read
> and less chance of conflict with other code. I would much rather "know"
> that a variable exists and see what values it contains than hope it exists.
>
> It also cuts down you coding as you only have to say
>
> <cfif x eq "somevalue">
> ....
> </cfif>
>
> rather than
>
> <cfif isDefined("x" and x eq "somevalue">
> ....
> </cfif>
>
> Anyway. That is a very quick reason and something that I could rant on
> about for ages but hopefully gives a little idea about why I don't like
> isDefined.
>
> I have not come across a reason to use isDefined accept in an error handler.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"cfaussie" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cfaussie?hl=en
-~----------~----~----~----~------~----~------~--~---