In short, your first example is processing a variable. Your second
example is processing a string. CF Treats strings and variables
differently; so this is not an inconsistency.
More in depth:
ColdFusion (and every other language I've worked with) uses quotes to
distinguish a literal string from a variable. If it's in quotes, it's a
string. if it's not in quotes it's a variable.
( This is also why variables can't begin with a number; because there
would be no way to distinguish them from a numeric literal )
In your first example:
#parsedData.ItemLookupResponse.Items.Item.Offers.Offer[i].Seller.SellerId.XmlText#
CF is processing a variable (as specified from by the pound
signs). Since the 'i' in the offer array (or structure) is not in quotes,
it assumes it is an embedded variable and returns the value of the
variable, instead of a string literal.
However in your second example:
isDefined("parsedData.ItemLookupResponse.Items.Item.Offers.Offer[i].Seller.SellerId.XmlText")
You are passing the IsDefined function a string. The whole variable name
is in quotes; and none of it is 'translated'. ColdFusion doesn't know to
treat the 'i' as a variable, it is just another part of the string. The
'i' should either be in quotes (for a structure) or numeric (for an
array). It is neither. That is why you get the problem.
This might work:
isDefined("parsedData.ItemLookupResponse.Items.Item.Offers.Offer[#i#].Seller.SellerId.XmlText")
You may be better off investigating "StructKeyExists" or Arraylen to make
sure you are not accessing an invalid value.
At 09:08 AM 4/11/2006, you wrote:
>Subject: CF Inconsistency
>From: "James Smith" <[EMAIL PROTECTED]>
>Date: Tue, 11 Apr 2006 10:02:24 +0100
>Thread:
>http://www.houseoffusion.com/cf_lists/index.cfm/method=messages&threadid=21087&forumid=5#203626
>
>Just out of interest, why is...
>
>#parsedData.ItemLookupResponse.Items.Item.Offers.Offer[i].Seller.SellerId.Xm
>lText#
>
>Perfectly valid, but
>
>isDefined("parsedData.ItemLookupResponse.Items.Item.Offers.Offer[i].Seller.S
>ellerId.XmlText")
>
>Throws the error "must be a syntactically valid variable name".
>IT IS!!! YOU JUST OUTPUT IT!!!
>
>Why must the square brackets be changed to hash marks and vice-versa
>depending on where you use it!
>
>--
>James Smith
>IT Director - Music Express
>
>--
>No virus found in this outgoing message.
>Checked by AVG Free Edition.
>Version: 7.1.385 / Virus Database: 268.4.1/307 - Release Date: 10/04/2006
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Message: http://www.houseoffusion.com/lists.cfm/link=i:5:203633
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/5
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:5
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.5
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54