Thanks to everyone who replied.
I knew I could use isdefined(aStruct.aField) but
I was just wondering what the rationale was behind
invalid syntax error for
isdefined(aStruct['aField']). Dave's explanation
that I should really think of it as two separate tests
was pretty good.
Also, I don't
The following code throws a syntax error:
cfset aStruct=StructNew()
cfset aStruct.aField=something
cfif IsDefined(aStruct[aField])
aStruct[aField] is defined
/cfif
Is this just some CF quirk that IsDefined doesn't like
brackets or is there some good reason for this?
=
I-Lin Kuo
and brackets
The following code throws a syntax error:
cfset aStruct=StructNew()
cfset aStruct.aField=something
cfif IsDefined(aStruct[aField])
aStruct[aField] is defined
/cfif
Is this just some CF quirk that IsDefined doesn't like
brackets or is there some good reason for this?
=
I
: Thursday, April 18, 2002 9:04 AM
Subject: RE: IsDefined and brackets
I believe that IsDefined is only meant to check for the existance of top
level variables, for complex data types you have to use the specific
functions for each type. So here CF is trying to find out if there is a
variable
The following code throws a syntax error:
cfset aStruct=StructNew()
cfset aStruct.aField=something
cfif IsDefined(aStruct[aField])
aStruct[aField] is defined
/cfif
Is this just some CF quirk that IsDefined doesn't like
brackets or is there some good reason for this?
You could
CF quirk that IsDefined doesn't like
brackets or is there some good reason for this?
=
I-Lin Kuo
Macromedia CF5 Advanced Developer
Sun Certified Java 2 Programmer
__
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http
PROTECTED]
Yahoo IM : morpheus
My ally is the Force, and a powerful ally it is. - Yoda
-Original Message-
From: cf refactoring [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 18, 2002 11:50 AM
To: CF-Talk
Subject: IsDefined and brackets
The following code throws a syntax error
Why not simply
cfif isdefined(aStruct.aField) ?
- Original Message -
From: Dave Watts [EMAIL PROTECTED]
You could rewrite this test to look like this:
cfif IsDefined(aStruct) and StructKeyExists(aStruct, aField)
This clearly describes the two tests you're running.
Dave Watts, CTO,
()
cfset aStruct.aField=something
cfif IsDefined(aStruct[aField])
aStruct[aField] is defined
/cfif
Is this just some CF quirk that IsDefined doesn't like
brackets or is there some good reason for this?
=
I-Lin Kuo
Macromedia CF5 Advanced Developer
Sun Certified Java 2 Programmer
Why not simply
cfif isdefined(aStruct.aField) ?
I implied in my original post that you could use dot notation, as opposed to
array syntax.
If you use dot notation, it's clear that you're
referencing a variable within a structure, I suppose,
which entails checking the existence of both the
[EMAIL PROTECTED]
Sent: Thursday, April 18, 2002 8:50 AM
Subject: IsDefined and brackets
The following code throws a syntax error:
cfset aStruct=StructNew()
cfset aStruct.aField=something
cfif IsDefined(aStruct[aField])
aStruct[aField] is defined
/cfif
Is this just some CF quirk
11 matches
Mail list logo