Discussion:
Multidimensional Arrays
Craig Boyd
2011-02-01 16:44:32 UTC
Permalink
Is there someplace that has some information/tutorials on working with
multidimensional arrays?

The LR is a bit sparse on this topic...



Thanks,



Craigbert

</pre><font face="monospace"size="-3"><br>The information transmitted is intended only for the person or entity to which it is addressed and <br>may contain confidential and/or privileged material. If the reader of this message is not the intended<br>recipient, you are hereby notified that your access is unauthorized, and any review, dissemination,<br>distribution or copying of this message including any attachments is strictly prohibited. If you are not<br>the intended recipient, please contact the sender and delete the material from any computer.<br><pre>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Jon Ogden
2011-02-01 17:01:23 UTC
Permalink
Post by Craig Boyd
Is there someplace that has some information/tutorials on working with
multidimensional arrays?
It's a rather open ended question. What would you like to know specifically?

Jon

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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Craig Boyd
2011-02-01 17:14:52 UTC
Permalink
Here are some of my questions:
If I REDIM NameArray(-1,-1) how do start adding entries into the array?
Append does not work and specifying the exact location [ NameArray(0,0)
= "Craig" ] does not work.

I found an example of how to use Ubound so I am OK with that.

What other functions will work with Multidimensional arrays? For those
that don't how do I work around them?

Better? :)

Thanks,

Craigbert
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete the material from any
computer.


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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Jon Ogden
2011-02-01 17:25:43 UTC
Permalink
Post by Craig Boyd
If I REDIM NameArray(-1,-1) how do start adding entries into the array?
Append does not work and specifying the exact location [ NameArray(0,0)
= "Craig" ] does not work.
I found an example of how to use Ubound so I am OK with that.
What other functions will work with Multidimensional arrays? For those
that don't how do I work around them?
I believe functions like Append, Split, Join, etc. all work only with 1 dimensional arrays. So you probably need to actually specify a dimension that you want. If the array is going to grow, I would try redimensioning it as you go:

For i as integer = 0 to MyMax_X_Value
For j as integer = 0 to MyMax_Y_Value
Redim NameArray(i,j)
NameArray(i,j) = Some_String_Value
Next
Next

I would imagine that's how you'd have to do it. If there's an easier way, I'd like to know. But I tend to stick with one dimensional arrays most of the time precisely because they are easier to work with given all the nice functions that RS provides for them.

Jon

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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Craig Boyd
2011-02-01 17:48:13 UTC
Permalink
Thanks Jon. That does not look too painful.

Craigbert

-----Original Message-----
From: realbasic-nug-bounces-Gjhu/N1EzaPthnj+***@public.gmane.org
[mailto:realbasic-nug-bounces-Gjhu/N1EzaPthnj+***@public.gmane.org] On Behalf Of Jon
Ogden
Sent: Tuesday, February 01, 2011 11:26 AM
To: REALbasic NUG
Subject: Re: Multidimensional Arrays
Post by Craig Boyd
If I REDIM NameArray(-1,-1) how do start adding entries into the array?
Append does not work and specifying the exact location [
NameArray(0,0)
Post by Craig Boyd
= "Craig" ] does not work.
I found an example of how to use Ubound so I am OK with that.
What other functions will work with Multidimensional arrays? For those
that don't how do I work around them?
I believe functions like Append, Split, Join, etc. all work only with 1
dimensional arrays. So you probably need to actually specify a
dimension that you want. If the array is going to grow, I would try
redimensioning it as you go:

For i as integer = 0 to MyMax_X_Value
For j as integer = 0 to MyMax_Y_Value
Redim NameArray(i,j)
NameArray(i,j) = Some_String_Value
Next
Next

I would imagine that's how you'd have to do it. If there's an easier
way, I'd like to know. But I tend to stick with one dimensional arrays
most of the time precisely because they are easier to work with given
all the nice functions that RS provides for them.

Jon

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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete the material from any
computer.


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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Charles Yeomans
2011-02-01 17:57:18 UTC
Permalink
But it does to me. Instead, do

Redim NameArray(MyMax_X_Value, MyMax_Y_Value)
For i as integer = 0 to MyMax_X_Value
For j as integer = 0 to MyMax_Y_Value
NameArray(i,j) = Some_String_Value
Next
Next


Charles Yeomans
Post by Craig Boyd
Thanks Jon. That does not look too painful.
Craigbert
-----Original Message-----
Ogden
Sent: Tuesday, February 01, 2011 11:26 AM
To: REALbasic NUG
Subject: Re: Multidimensional Arrays
Post by Craig Boyd
If I REDIM NameArray(-1,-1) how do start adding entries into the
array?
Post by Craig Boyd
Append does not work and specifying the exact location [
NameArray(0,0)
Post by Craig Boyd
= "Craig" ] does not work.
I found an example of how to use Ubound so I am OK with that.
What other functions will work with Multidimensional arrays? For
those
Post by Craig Boyd
that don't how do I work around them?
I believe functions like Append, Split, Join, etc. all work only with 1
dimensional arrays. So you probably need to actually specify a
dimension that you want. If the array is going to grow, I would try
For i as integer = 0 to MyMax_X_Value
For j as integer = 0 to MyMax_Y_Value
Redim NameArray(i,j)
NameArray(i,j) = Some_String_Value
Next
Next
I would imagine that's how you'd have to do it. If there's an easier
way, I'd like to know. But I tend to stick with one dimensional arrays
most of the time precisely because they are easier to work with given
all the nice functions that RS provides for them.
Jon
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Craig Boyd
2011-02-01 18:15:34 UTC
Permalink
Thanks Charles, that is a bit tighter.

Craigbert

-----Original Message-----
From: realbasic-nug-bounces-Gjhu/N1EzaPthnj+***@public.gmane.org
[mailto:realbasic-nug-bounces-Gjhu/N1EzaPthnj+***@public.gmane.org] On Behalf Of
Charles Yeomans
Sent: Tuesday, February 01, 2011 11:57 AM
To: REALbasic NUG
Subject: Re: Multidimensional Arrays

But it does to me. Instead, do

Redim NameArray(MyMax_X_Value, MyMax_Y_Value)
For i as integer = 0 to MyMax_X_Value
For j as integer = 0 to MyMax_Y_Value
NameArray(i,j) = Some_String_Value
Next
Next


Charles Yeomans
Post by Craig Boyd
Thanks Jon. That does not look too painful.
Craigbert
-----Original Message-----
Ogden
Sent: Tuesday, February 01, 2011 11:26 AM
To: REALbasic NUG
Subject: Re: Multidimensional Arrays
Post by Craig Boyd
If I REDIM NameArray(-1,-1) how do start adding entries into the
array?
Post by Craig Boyd
Append does not work and specifying the exact location [
NameArray(0,0)
Post by Craig Boyd
= "Craig" ] does not work.
I found an example of how to use Ubound so I am OK with that.
What other functions will work with Multidimensional arrays? For
those
Post by Craig Boyd
that don't how do I work around them?
I believe functions like Append, Split, Join, etc. all work only with 1
dimensional arrays. So you probably need to actually specify a
dimension that you want. If the array is going to grow, I would try
For i as integer = 0 to MyMax_X_Value
For j as integer = 0 to MyMax_Y_Value
Redim NameArray(i,j)
NameArray(i,j) = Some_String_Value
Next
Next
I would imagine that's how you'd have to do it. If there's an easier
way, I'd like to know. But I tend to stick with one dimensional arrays
most of the time precisely because they are easier to work with given
all the nice functions that RS provides for them.
Jon
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete the material from any
computer.


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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Jon Ogden
2011-02-01 18:22:09 UTC
Permalink
Sure, that's better. No need to redimension each loop. I was simply trying to show how you could dynamically resize the array.

Jon

Sent from my iPhone
Post by Charles Yeomans
But it does to me. Instead, do
Redim NameArray(MyMax_X_Value, MyMax_Y_Value)
For i as integer = 0 to MyMax_X_Value
For j as integer = 0 to MyMax_Y_Value
NameArray(i,j) = Some_String_Value
Next
Next
Charles Yeomans
Post by Craig Boyd
Thanks Jon. That does not look too painful.
Craigbert
-----Original Message-----
Ogden
Sent: Tuesday, February 01, 2011 11:26 AM
To: REALbasic NUG
Subject: Re: Multidimensional Arrays
Post by Craig Boyd
If I REDIM NameArray(-1,-1) how do start adding entries into the
array?
Post by Craig Boyd
Append does not work and specifying the exact location [
NameArray(0,0)
Post by Craig Boyd
= "Craig" ] does not work.
I found an example of how to use Ubound so I am OK with that.
What other functions will work with Multidimensional arrays? For
those
Post by Craig Boyd
that don't how do I work around them?
I believe functions like Append, Split, Join, etc. all work only with 1
dimensional arrays. So you probably need to actually specify a
dimension that you want. If the array is going to grow, I would try
For i as integer = 0 to MyMax_X_Value
For j as integer = 0 to MyMax_Y_Value
Redim NameArray(i,j)
NameArray(i,j) = Some_String_Value
Next
Next
I would imagine that's how you'd have to do it. If there's an easier
way, I'd like to know. But I tend to stick with one dimensional arrays
most of the time precisely because they are easier to work with given
all the nice functions that RS provides for them.
Jon
_______________________________________________
<http://www.realsoftware.com/support/listmanager/>
<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>
Charles Yeomans
2011-02-01 17:31:15 UTC
Permalink
Post by Craig Boyd
If I REDIM NameArray(-1,-1) how do start adding entries into the array?
Append does not work and specifying the exact location [ NameArray(0,0)
= "Craig" ] does not work.
I found an example of how to use Ubound so I am OK with that.
What other functions will work with Multidimensional arrays? For those
that don't how do I work around them?
Better? :)
Yes, but not good enough. It would be useful for you to say how ' NameArray(0,0) = "Craig""' does not work.

Unlike one-dimensional arrays, multi-dimensional arrays cannot be resized dynamically, as happens when one calls Array.Append on a 1-D array. Instead, you must specify the array dimensions in advance.

dim NameArray(0, 0) as String
NameArray(0, 0) = "Craig"


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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Christian Schmitz
2011-02-01 17:42:30 UTC
Permalink
Hi,

Check out ubound with it's extra parameter:
http://docs.realsoftware.com/index.php/Ubound

and use redim to add new rows or columns:
http://docs.realsoftware.com/index.php/Redim

Greetings
Christian
--
See you in Atlanta (USA) at the REAL Studio Summit 2011

Registration and details here:
http://arbpmembers.org/real-studio-summit-2011/



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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Craig Boyd
2011-02-01 17:45:26 UTC
Permalink
Charles,

Thanks for demanding precision. I get an "0ut of bounds error".

I am sure it is because I was trying to resize the dimension
dynamically.
How silly of me to expect it to behave like its cousin the one
dimensional array.

Thanks,

Craigbert

-----Original Message-----
From: realbasic-nug-bounces-Gjhu/N1EzaPthnj+***@public.gmane.org
[mailto:realbasic-nug-bounces-Gjhu/N1EzaPthnj+***@public.gmane.org] On Behalf Of
Charles Yeomans
Sent: Tuesday, February 01, 2011 11:31 AM
To: REALbasic NUG
Subject: Re: Multidimensional Arrays
Post by Craig Boyd
If I REDIM NameArray(-1,-1) how do start adding entries into the array?
Append does not work and specifying the exact location [
NameArray(0,0)
Post by Craig Boyd
= "Craig" ] does not work.
I found an example of how to use Ubound so I am OK with that.
What other functions will work with Multidimensional arrays? For those
that don't how do I work around them?
Better? :)
Yes, but not good enough. It would be useful for you to say how '
NameArray(0,0) = "Craig""' does not work.

Unlike one-dimensional arrays, multi-dimensional arrays cannot be
resized dynamically, as happens when one calls Array.Append on a 1-D
array. Instead, you must specify the array dimensions in advance.

dim NameArray(0, 0) as String
NameArray(0, 0) = "Craig"


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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete the material from any
computer.


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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Charles Yeomans
2011-02-01 18:16:32 UTC
Permalink
Hmmm; I see why you and others might be having issues; the documentation for arrays is not entirely correct in places.

Charles Yeomans
Post by Craig Boyd
Charles,
Thanks for demanding precision. I get an "0ut of bounds error".
I am sure it is because I was trying to resize the dimension
dynamically.
How silly of me to expect it to behave like its cousin the one
dimensional array.
Thanks,
Craigbert
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Craig Boyd
2011-02-01 18:19:52 UTC
Permalink
Please tell me you are one of the minor deities that can update the
sacred site?

Craigbert

-----Original Message-----
From: realbasic-nug-bounces-Gjhu/N1EzaPthnj+***@public.gmane.org
[mailto:realbasic-nug-bounces-Gjhu/N1EzaPthnj+***@public.gmane.org] On Behalf Of
Charles Yeomans
Sent: Tuesday, February 01, 2011 12:17 PM
To: REALbasic NUG
Subject: Re: Multidimensional Arrays

Hmmm; I see why you and others might be having issues; the documentation
for arrays is not entirely correct in places.

Charles Yeomans
Post by Craig Boyd
Charles,
Thanks for demanding precision. I get an "0ut of bounds error".
I am sure it is because I was trying to resize the dimension
dynamically.
How silly of me to expect it to behave like its cousin the one
dimensional array.
Thanks,
Craigbert
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
The information transmitted is intended only for the person or entity to
which it is addressed and may contain confidential and/or privileged
material. If the reader of this message is not the intended recipient,
you are hereby notified that your access is unauthorized, and any review,
dissemination, distribution or copying of this message including any
attachments is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete the material from any
computer.


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

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>
Charles Yeomans
2011-02-01 22:02:30 UTC
Permalink
I am, but my time for such tasks is limited.

Charles Yeomans
Post by Craig Boyd
Please tell me you are one of the minor deities that can update the
sacred site?
Craigbert
-----Original Message-----
Charles Yeomans
Sent: Tuesday, February 01, 2011 12:17 PM
To: REALbasic NUG
Subject: Re: Multidimensional Arrays
Hmmm; I see why you and others might be having issues; the documentation
for arrays is not entirely correct in places.
Charles Yeomans
Post by Craig Boyd
Charles,
Thanks for demanding precision. I get an "0ut of bounds error".
I am sure it is because I was trying to resize the dimension
dynamically.
How silly of me to expect it to behave like its cousin the one
dimensional array.
Thanks,
Craigbert
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

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

Loading...