<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc = "http://purl.org/dc/elements/1.1/" xmlns="http://purl.org/rss/1.0/">
	<channel rdf:about="http://livedocs.adobe.com/">
	<title>LiveDocs Comments - coldfusion - 6 - Developing_ColdFusion_MX_Applications_with_CFML - Variables8.htm</title>	
		<link>http://livedocs.adobe.com/</link>
		<description>Macromedia LiveDocs - online documentation with user feedback.</description>
		<copyright>Copyright 2009, Macromedia, Inc.</copyright>
		<dc:date>2009-11-25T03:21:43</dc:date>
		<dc:language>en-us</dc:language>
		<items>
			<rdf:Seq>
				<rdf:li rdf:resource="http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables8.htm#59318" />
				<rdf:li rdf:resource="http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables8.htm#48344" />
				<rdf:li rdf:resource="http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables8.htm#26681" />
			</rdf:Seq>
		</items>
	</channel>
	
	<item rdf:about="http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables8.htm#59318">
		<title>coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables8.htm</title>
		<link>http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables8.htm#59318</link>
		<description>Hey guys,&lt;br /&gt;Just wanted to let you know that the udf from &quot;CannedRadio&quot;, really helped me. I am inside a loop looking ahead of myself to check a value, and I needed to make sure that the iterator of my inner loop was a valid array element number. The others may have worked also, but this one was the clearest one I could impliment. P.S. Shouldnt one of these functions be added to CF? It only seems logical that they would have it built in for us to be able to check to see if an array element existed.&lt;br /&gt;&lt;br /&gt;Thanks though,&lt;br /&gt;Timothy D Farar</description>
		<dc:creator>timothyFarrar</dc:creator>
		<dc:type>0 0</dc:type>
		<dc:date>2007-01-10T09:13:06</dc:date>
	</item>
	<item rdf:about="http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables8.htm#48344">
		<title>coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables8.htm</title>
		<link>http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables8.htm#48344</link>
		<description>Over at CFDJ, Charlie Arehart found a munch faster solution to this I thought I would share here:&lt;br /&gt;&lt;br /&gt;Quoted from the article at &lt;a href=&quot;http://cfdj.sys-con.com/read/41900.htm&quot;&gt;http://cfdj.sys-con.com/read/41900.htm&lt;/a&gt;&lt;br /&gt;&lt;br /&gt; We mentioned earlier that prepopulating the array could solve the problem by ensuring there was always a value in each array element. That seems kludgy, especially doing some sort of loop to put a default value in each element and then testing for that default during each iteration through the array. Indeed, there are times when that wouldn't be appropriate anyway, since it may be significant that there's no value in particular array elements, or it may lead to lots of extra bytes of information in an otherwise large, sparse array.&lt;br /&gt;&lt;br /&gt;Still, if that solution has appeal, there's still one more approach that may be at least a little less kludgy. Rather than loop through the array to prepopulate it (or deal with CFTRY/ CFCATCH to detect errors), you could use CFPARAM within the loop while iterating through the array. This will assign a default empty string to any array elements that are otherwise &quot;not defined,&quot; then test for that value to determine which array elements have value. The change to the loop above would be:&lt;br /&gt;&lt;br /&gt;    &lt;CFLOOP FROM=&quot;1&quot; TO=&quot;#ArrayLen(ACart)#&quot; INDEX=&quot;i&quot;&gt;&lt;br /&gt;    &lt;CFPARAM NAME=&quot;Acart[i]&quot; DEFAULT=&quot;&quot;&gt;&lt;br /&gt;    &lt;CFIF Acart[i] is not &quot;&quot;&gt;&lt;br /&gt;    Item: #ACart[i]# &lt;br&gt;&lt;br /&gt;    &lt;/CFIF&gt;&lt;br /&gt;    &lt;/CFLOOP&gt; &lt;br /&gt;&lt;br /&gt;CFPARAM says, &quot;If the named variable doesn't exist, create it and populate it with the given default value.&quot; Now, unlike the test for IsDefined(), the test that follows will never result in a runtime error, and it'll only print an array element if it has content. (If you need to distinguish between an element whose value is already an empty string and one whose value is assigned via CFPARAM, change the DEFAULT and test using some other unlikely value.)&lt;br /&gt;&lt;br /&gt;Thanks to developer Tim Painter and instructor Emily Kim, who both shared this solution with me.</description>
		<dc:creator>override11</dc:creator>
		<dc:type>0 0</dc:type>
		<dc:date>2006-05-08T06:36:21</dc:date>
	</item>
	<item rdf:about="http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables8.htm#26681">
		<title>coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables8.htm</title>
		<link>http://livedocs.adobe.com/coldfusion/6/Developing_ColdFusion_MX_Applications_with_CFML/Variables8.htm#26681</link>
		<description>IsDefined(&quot;myArray[3]&quot;) does not return &quot;false&quot; it produces an error.  Tested in CF 5, mx, mx 6.1.  You can not check for the existence of an array element, by copying the element to a simple variable and use IsDefined to test whether the simple variable exists, because you get a  error trying to use the array to set the simple variable. &lt;br /&gt;here is a helpful udf with example you may use until CF can handle this requirement.&lt;br /&gt;&lt;br /&gt;&lt;cfscript&gt;&lt;br /&gt;    function isArrayElementDefined(arrayName){&lt;br /&gt;        try{&lt;br /&gt;            testArrayVal = evaluate(arrayName);&lt;br /&gt;            return true;&lt;br /&gt;        }catch(any testForArrayElement){&lt;br /&gt;            return false;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;&lt;/cfscript&gt;&lt;br /&gt;&lt;cfset myArray = arrayNew(1)&gt;&lt;br /&gt;&lt;cfset myArray[1] = &quot;bob&quot;&gt;&lt;br /&gt;&lt;cfset myArray[3] = &quot;joe&quot;&gt;&lt;br /&gt;&lt;cfoutput&gt;&lt;br /&gt;  &lt;cfloop from = &quot;1&quot; to = &quot;3&quot; index = &quot;place&quot;&gt;&lt;br /&gt;    #isArrayElementDefined(&quot;myArray[#place#]&quot;)#&lt;br /&gt;  &lt;/cfloop&gt;&lt;br /&gt;&lt;/cfoutput&gt;&lt;br /&gt;&lt;br /&gt;output: true false true</description>
		<dc:creator>cannedRadio</dc:creator>
		<dc:type>0 0</dc:type>
		<dc:date>2005-01-18T11:04:42</dc:date>
	</item>
	</rdf:RDF>

