macromedia.coldfusion.cfml_general_discussion
[Top] [All Lists]

Re: Multi-dimensional array

Subject: Re: Multi-dimensional array
From: Adam Cameron
Date: Thu, 30 Aug 2007 22:38:35 +0100
Newsgroups: macromedia.coldfusion.cfml_general_discussion
>  "It worked fine untill one of my users set up a csv file, deleted some rows, 
> then uploaded."

Sure.  But that's the CSV file.  Why/how did the empty rows / elements get
INTO THE ARRAY.

My question was kind of leading towards: maybe it's better to not put the
empty rows in in the first place, than having to have code to deal with
them after the fact.

To answer your actual question, there's nothing native in CFMX7 which will
detect (without throwing an exception) a null array element.

However one can do it with Java, thus:

v = a.elementAt(i-1);   // where i is the array index to test
if (isDefined("v"){
        // all good
} else {
        // didn't exist
}

CF8 brings in arrayIsDefined()
(http://livedocs.adobe.com/coldfusion/8/functions_a-b_12.html)

However... I reiterate: you're better off not putting the blank records in
in the first place.  Work out why it's happening, and fix THAT.

-- 
Adam

<Prev in Thread] Current Thread [Next in Thread>