reference. structKeyExists looks for the named key in the named
struct/scope. IsDefined, as you might imagine, performs significantly
more work to get it's job done.
structKeyExists(application, "myThing") first finds the 'application'
variable (which happens to be a scope), and then sees if there is a
key named 'myThing' inside.
isDefined("application.myThing") has to check for 'myThing' in the
application scope, along with 'application.myThing' in all of the
implicit scopes (variables, url, form, cgi, maybe others).
If you don't know where a varaible is, then isDefined is a must, but
in general structKeyExists is a more efficient way to go, because you
usually know where the variable you're checking for should live
(application scope, in this case).
The one exception is for local variables inside a function. There
isn't a "local" scope that you can use structKeyExists against, so
you're forced to use isDefined. Note, however, that because of the
weird arguments/local vars setup in CFMX, if you're checking on an
argument, you can use structKeyExists on the arguments scope and get
the correct behaviour.
cheers,
barneyb
On Mon, 18 Oct 2004 16:07:13 -0400, Johnny Le <[EMAIL PROTECTED]> wrote:
> Hi Barney,
>
> That is exactly what I was looking for. I should have thought of that.
>
> Your code brings up another question. Is there any difference between structKeyExists and IsDefined? Why should someone use structKeyExists instead of IsDefined since IsDefined is simplier to remember?
>
> Johnny
--
Barney Boisvert
[EMAIL PROTECTED]
360.319.6145
http://www.barneyb.com/blog/
I currently have 2 GMail invites for the taking
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

