Hi,
Further to Jacques email, I believe you can do it with both dimensions being
created dynamically. The following is a rework of how I handle an array
normally, so it is in the same format as Jacques. The disclaimer is that
this code is off the top of my head and I haven't actually tested this
precise code, but you should get the idea. I know I should never take a
short cut like that, but hopefully the disclaimer can bypass that :-)
Type tRow
colJ() as float
end Type
dim rowI() as tRow
....
dim iRowCount as smallint
dim iColoumnCount as smallint
dim iIndex as smallint
iRowCount = 3
iColCount = 2
redim rowI(iRowCount)
for iIndex = 1 to iRowCount
redim rowI(iIndex).ColJ(iColumnCount)
next
You now have a standard 3x2 rectangular matrix.
A rectangular matrix is not always required, unless the requirement is
mathematical. I normally build the columns required for the first "row",
then increment the row array and build the columns required for the second
"row". Doesn't really sound practical if only thinking about rows and
columns, but it is very useful for storage of programatic data that is
essentially like one to many to many.
To date, I have only used 2D arrays, but theoretically it is not limited in
the number of dimensions. I think the limitation would lie with the redim
statement:
redim rowI(iIndex).ColJ(iColumnCount).......
Hope I got this right, and let me know if there's a problem.
Lorraine Donaldson
GIS Applications Programmer
Data Directions
240 Jersey Street,
Wembley, WA 6014
Australia
mobile: 0401 67 1889
fax: 08 9387 1265
email: [EMAIL PROTECTED]
web: www.datadirections.com.au
----- Original Message -----
From: "Jacques Paris" <[EMAIL PROTECTED]>
To: "Peter Horsb�ll M�ller" <[EMAIL PROTECTED]>; "MIL"
<[EMAIL PROTECTED]>
Sent: Friday, January 31, 2003 8:51 PM
Subject: RE: MI-L Mapinfo.Net ?
I have tried to develop that concept a little further to make it more like a
standard x(i,j) type array and here is the way I have implemented it
type trow
colJ(2) as float
end type
type array
nrow as integer
rowI() as trow
end type
dim vrow as trow, arr as array
dim i, j as smallint
arr.nrow=3
redim arr.rowI(arr.nrow)
for i=1 to 3
for j=1 to 2
arr.rowI(i).colJ(j)=10+i*1+j*3.2
next
next
for i =1 to 3
for j =1 to 2
print arr.rowI(i).colJ(j)
next
next
You can notice that the I dimension (number of rows) can be dynamically
redim'ed but that the J (number of columns) must be dim'ed directly in the
type statement.
Would anyone have another insight that would make that solution more
flexible?
Jacques Paris
e-mail [EMAIL PROTECTED]
MapBasic-MapInfo support http://www.paris-pc-gis.com
---------------------------------------------------------------------
List hosting provided by Directions Magazine | www.directionsmag.com |
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
Message number: 5273