Passing arrays
Author |
Message |
chrisbrown
![](http://compsci.ca/v3/uploads/user_avatars/18814724584bcbb8192aae8.png)
|
Posted: Sat Feb 18, 2006 5:47 pm Post subject: Passing arrays |
|
|
I don't know if this has been addressed in this forum; I gave up serching through the 63 pages of hits the search term "passing arrays" returned. Anyways, I'm writing a football game and I need to pass a 2D array to a procedure which will then write the contents of that array to a file. The I/O is no problem for me, but if anyone knows how to pass arrays please let me know.
Thanks |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Cervantes
![](http://compsci.ca/v3/uploads/user_avatars/1023105758475ab2e040bde.jpg)
|
Posted: Sat Feb 18, 2006 6:01 pm Post subject: (No subject) |
|
|
Welcome to CompSci.ca!
You can pass an array into a procedure, like this:
code: |
proc test (arr : array 1 .. 10 of int)
|
Of course, what if the array doesn't end at 10?
code: |
proc test (arr : array 1 .. * of int)
|
This will accept an array with a lower bounds of 1 and an upper bounds of mostly anything.
A 2D array can be done like this:
code: |
proc test (arr : array 1 .. *, 1 .. * of int)
|
Here's an example:
code: |
proc test (arr : array 1 .. *, 1 .. * of int)
put arr (1, 1)
end test
var my_arr : array 1 .. 5, 1 .. 3 of int
my_arr (1, 1) := 42
test (arr)
|
|
|
|
|
|
![](images/spacer.gif) |
Delos
![](http://www.members.shaw.ca/rfolz/delos_avatar.gif)
|
Posted: Sat Feb 18, 2006 11:00 pm Post subject: (No subject) |
|
|
Or do you mean parse? That would entail an analysis of each element and redistribution based upon their inherent structures as per your afore setup grammatical structure...
Or something like that. Listen to Cervantes. |
|
|
|
|
![](images/spacer.gif) |
|
|