Xojo Conferences
MBSSep2018MunichDE
XDCMay2019MiamiUSA

Arrays of Arrays vs. Multidimensional Arrays vs... (Real Studio network user group Mailinglist archive)

Back to the thread list
Previous thread: Expanding BIN files
Next thread: App for Adding Resources to Mac Bundle


FW: Special Valentine's Offer for Valentina - Beat the Price Increase!   -   Lynn Fredricks
  Arrays of Arrays vs. Multidimensional Arrays vs...   -   Michael Diehr
   Re: Arrays of Arrays vs. Multidimensional Arrays vs...   -   Daniel Stenning
   Re: Arrays of Arrays vs. Multidimensional Arrays vs...   -   joe strout.net
    Re: Arrays of Arrays vs. Multidimensional Arrays vs...   -   Michael Diehr
    Re: Arrays of Arrays vs. Multidimensional Arrays vs...   -   Michael Diehr
    Re: Arrays of Arrays vs. Multidimensional Arrays vs...   -   Karen
   Re: Arrays of Arrays vs. Multidimensional Arrays vs...   -   Rubber Chicken Software Co.
    Re: Arrays of Arrays vs. Multidimensional Arrays vs...   -   joe strout.net
   Re: Arrays of Arrays vs. Multidimensional Arrays vs...   -   Michael Diehr

Arrays of Arrays vs. Multidimensional Arrays vs...
Date: 04.08.07 02:49 (Fri, 3 Aug 2007 18:49:03 -0700)
From: Michael Diehr
Trying to return a two dimensional matrix of data from a function and
was encountering some problems. It seems like REALbasic does not
make 2D data very easy to handle. Single dimensional arrays are
fine, but arrays with 2 dimensions seem rather awkward to work
with. In particular, Redim seems broken, so I can't figure out how
exactly to cause a function which makes and returns a 2d array of
arbitrary size at runtime. Any thoughts on this? Is the solution
to return an Array of Arrays?
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Arrays of Arrays vs. Multidimensional Arrays vs...
Date: 04.08.07 02:55 (Sat, 04 Aug 2007 02:55:25 +0100)
From: Daniel Stenning
I wish, but sadly this isnt a feature yet. Theres an FR for it somewhere.

On 4/8/07 02:49, "Michael Diehr" <<email address removed>> wrote:

> Any thoughts on this? Is the solution
> to return an Array of Arrays?

Cheers,
Dan



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Arrays of Arrays vs. Multidimensional Arrays vs...
Date: 05.08.07 02:13 (Sat, 4 Aug 2007 19:13:18 -0600)
From: joe strout.net
On Aug 04, 2007, at 01:49 UTC, Michael Diehr wrote:

> Trying to return a two dimensional matrix of data from a function and
> was encountering some problems. It seems like REALbasic does not
> make 2D data very easy to handle. Single dimensional arrays are
> fine, but arrays with 2 dimensions seem rather awkward to work
> with.

How so?

> In particular, Redim seems broken, so I can't figure out how
> exactly to cause a function which makes and returns a 2d array of
> arbitrary size at runtime.

I've used Redim with 2D arrays many times, and never found it broken.
In what way is it not working for you?

Best,
- Joe

Re: Arrays of Arrays vs. Multidimensional Arrays vs...
Date: 06.08.07 03:43 (Sun, 5 Aug 2007 19:43:21 -0700)
From: Michael Diehr
Hmm, looks like I was being somewhat stupid:

Since you can't say
dim r(xMax, yMax) as string
if xMax and yMax are variables,

I was trying to do
dim r(,) as string
redim r(xMax,yMax)

but this fails on the first line.

Turns out you can do
dim r(0,0) as string
redim r(xMax,yMax)
and this works.

Seems like the not allowing "dim r(,)" is a little inconsistent and
threw me off.



On Aug 4, 2007, at 6:13 PM, <email address removed> wrote:

> On Aug 04, 2007, at 01:49 UTC, Michael Diehr wrote:
>
>> Trying to return a two dimensional matrix of data from a function and
>> was encountering some problems. It seems like REALbasic does not
>> make 2D data very easy to handle. Single dimensional arrays are
>> fine, but arrays with 2 dimensions seem rather awkward to work
>> with.
>
> How so?
>
>> In particular, Redim seems broken, so I can't figure out how
>> exactly to cause a function which makes and returns a 2d array of
>> arbitrary size at runtime.
>
> I've used Redim with 2D arrays many times, and never found it broken.
> In what way is it not working for you?
>
> Best,
> - Joe
>
> --
> Joe Strout -- <email address removed>
> Strout Custom Solutions, LLC
>
> _______________________________________________
> Unsubscribe or switch delivery mode:
> <http://www.realsoftware.com/support/listmanager/>
> Search the archives:
> <http://support.realsoftware.com/listarchives/lists.html>

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Arrays of Arrays vs. Multidimensional Arrays vs...
Date: 06.08.07 03:48 (Sun, 5 Aug 2007 19:48:44 -0700)
From: Michael Diehr
Another array issue:

dim r(,) as string
dim x,y as integer
x = ubound(r,1) // ok
y = ubound(r,2) // ok
y = r.ubound(2) // compile fails with message "only works for one-
dimensional arrays"

The language reference claims that both syntaxes are valid.

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Arrays of Arrays vs. Multidimensional Arrays vs...
Date: 06.08.07 03:59 (Sun, 5 Aug 2007 22:59:22 -0400)
From: Karen

On Aug 5, 2007, at 10:43 PM, Michael Diehr wrote:

> I was trying to do
> dim r(,) as string

That has tripped me up before as I expected it to work

>
> Turns out you can do
> dim r(0,0) as string
> redim r(xMax,yMax)
>

In theory i think:

dim r(-1,-1) as string

would be better in this case as it does not allocate any elements
initially. I think is also clearer logically, but I doubt it makes a
practical difference performance wise. In any case it's what I do. ;)

- Karen
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Arrays of Arrays vs. Multidimensional Arrays vs...
Date: 05.08.07 17:40 (Sun, 05 Aug 2007 11:40:48 -0500)
From: Rubber Chicken Software Co.
At 08:13 PM 8/4/2007, you wrote:

> > Trying to return a two dimensional matrix of data from a function and
> > was encountering some problems. It seems like REALbasic does not
> > make 2D data very easy to handle. Single dimensional arrays are
> > fine, but arrays with 2 dimensions seem rather awkward to work
> > with.
>
>How so?
>
> > In particular, Redim seems broken, so I can't figure out how
> > exactly to cause a function which makes and returns a 2d array of
> > arbitrary size at runtime.
>
>I've used Redim with 2D arrays many times, and never found it broken.
>In what way is it not working for you?

In the past, multi-dimensional arrays couldn't be passed to
functions. Has that changed?

Even if it has, I found my fundamental mistake was using the
multi-dim array when I should have been using a class; conceptually I
was hacking and the class would have been a more maintainable data container.

So although I'm sure there a good purposes for a multi-dimensional
array, consider a class if you are simply using the mutl-dim for data
handling.

Garth Hjelte
Sampler User

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>

Re: Arrays of Arrays vs. Multidimensional Arrays vs...
Date: 06.08.07 16:01 (Mon, 6 Aug 2007 09:01:29 -0600)
From: joe strout.net
On Aug 05, 2007, at 16:40 UTC, Rubber Chicken Software Co. wrote:

> In the past, multi-dimensional arrays couldn't be passed to
> functions. Has that changed?

Yes, many years ago. For example, to pass a 2D array of strings, you'd
declare the parameter as "foo(,) as String". A 3D array would be
"foo(,,) as String", and so on.

> Even if it has, I found my fundamental mistake was using the multi
> -dim array when I should have been using a class; conceptually I was
> hacking and the class would have been a more maintainable data
> container.

Yes, that can certainly be the case.

> So although I'm sure there a good purposes for a multi-dimensional
> array, consider a class if you are simply using the mutl-dim for data
> handling.

Good advice.

Best,
- Joe

Re: Arrays of Arrays vs. Multidimensional Arrays vs...
Date: 06.08.07 03:45 (Sun, 5 Aug 2007 19:45:56 -0700)
From: Michael Diehr
On Aug 5, 2007, at 9:40 AM, Rubber Chicken Software Co. wrote:

> In the past, multi-dimensional arrays couldn't be passed to
> functions. Has that changed?

yes, you can use
variableName(,) as type
syntax in a method declaration

> Even if it has, I found my fundamental mistake was using the
> multi-dim array when I should have been using a class; conceptually I
> was hacking and the class would have been a more maintainable data
> container.
>
> So although I'm sure there a good purposes for a multi-dimensional
> array, consider a class if you are simply using the mutl-dim for data
> handling.

Yes, absolutely -- I'm trying to do a quick prototyping hack, for
which handling an 2d array of data using the built-in type was the
most direct route. But, sometimes it's just not worth creating
another class & methods when you are trying to prototype...

_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>