In CF multi-dimensional arrays are just nested single-dimensional
arrays. Thus you could use the following syntax to get the max value of
the second dimension.

        ArrayMax(arrayName[1])

However, that assumes that there is only a single item in the first
dimension. This leads me to the following untested UDF.

        function UBound(array, dimension)
        {
                if(dimension eq 1)
                        return ArrayMax(array);
                else if(dimension eq 2)
                {
                        var tmpArray = ArrayNew(1);
                        for(itr = 1; itr lte ArrayLen(array); itr = itr
+ 1)
                                tmpArray[ArrayLen(tmpArray + 1)] =
ArrayMax(array[itr]);
                        return ArrayMax(tmpArray);
                }
                else
                {
                        //someone else can implement this case
                }
        }

-Matt

> -----Original Message-----
> From: Jeff Garza [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 28, 2002 10:32 PM
> To: CF-Talk
> Subject: RE: Unstructured info
> 
> The function UBound(arrayname, 2) returns the greatest value from the
> second
> dimension of the array ArrayName. The closest function in CF to this
is
> ArrayMax(arrayName) but that only returns the greatest value from a
one
> dimensional array.  You'll have to copy the values from second
dimension
> of
> your array to a separate array and then get the ArrayMax of the new
array.
> You might also want to check CFLib.org and see if there is a user
defined
> function that will deal with multi-dimensional arrays.
> 
> Jeff
> 
> -----Original Message-----
> From: David Jones [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, May 28, 2002 10:19 PM
> To: CF-Talk
> Subject: RE: Unstructured info
> 
> 
> This may sound like a silly question but I am having a hard time
figuring
> this out.
> 
> What is the CF equivalent to the VBScript UBound(arrayName,2)? I have
been
> all through the docs and cant find it.
> 
> Thanks,
> 
> Dave
> 
> 
> 
______________________________________________________________________
Get the mailserver that powers this list at http://www.coolfusion.com
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to