Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Multidimensional Arrays - dynamic?

626 views
Skip to first unread message

Julie Hill

unread,
Aug 20, 1999, 3:00:00 AM8/20/99
to

I think I'm trying to do something that PB 6.5 doesn't support. I need to
create a 3 dimensional array in PB, but it needs to be dynamic, e.g.

dc_points[N, 1, 2]

N represents an unknown number of elements. PB will only let me declare the
array with known values.

Does anyone have any suggestions??

Thanks
Julie Hill

Michael

unread,
Aug 20, 1999, 3:00:00 AM8/20/99
to

Here is an idea...

I assume you only need one dimension of the array to be dynamic And that you can
inverse the dimensions from [N, 1, 2] to [1, 2, N]

Create a structure with one element, e.g.
n[] decimal 1
That's a structure with one decimal dynamic array variable.

// Simulates a 3D array (5, 10, N)
s_points lstr_points[5, 10]

lstr_points[1, 1].N[1] = 1.1
lstr_points[1, 1].N[2] = 1.2
lstr_points[1, 1].N[3] = 1.3

MessageBox("1", lstr_points[1, 1].N[1])
MessageBox("2", lstr_points[1, 1].N[2])
MessageBox("3", lstr_points[1, 1].N[3])

Michael


On Fri, 20 Aug 1999 11:23:59 -0600,
in powersoft.public.powerbuilder.general

Michael

unread,
Aug 20, 1999, 3:00:00 AM8/20/99
to
Ummm... actually you don't need to inverse the dimensions of your array.

Create a structure with one element, e.g.

n[1, 2] decimal 1
That's a structure with a 2D decimal array variable.

// Simulates a 3D array (N, 1, 2)
s_points lstr_points[]

lstr_points[1].N[1, 1] = 1.1
lstr_points[1].N[1, 2] = 1.2
lstr_points[2].N[1, 1] = 2.1
lstr_points[2].N[1, 2] = 2.2


MessageBox("(1, 1, 1)", lstr_points[1].N[1, 1])
MessageBox("(1, 1, 2)", lstr_points[1].N[1, 2])
MessageBox("(2, 1, 1)", lstr_points[2].N[1, 1])
MessageBox("(2, 1, 2)", lstr_points[2].N[1, 2])

Michael


On Fri, 20 Aug 1999 13:42:14 -0400,
in powersoft.public.powerbuilder.general

Terry Voth

unread,
Aug 20, 1999, 3:00:00 AM8/20/99
to

How about an external datawindow, with columns:

dim1 number
dim2 number
dim3 number
value number??

Then, when you need the value, you can do something like

GetItemNumber (Find ("dim1=" +String (li_Dim1)+ " and dim2=" +String
(li_Dim2)+ " and dim3=" + String (li_Dim3), 1, RowCount ()), "value")

... with error checking on the Find(), of course.

Good luck,

Terry [TeamSybase] and Sequel the techno-kitten

On Fri, 20 Aug 1999 11:23:59 -0600, "Julie Hill" <julie...@gte.net>

0 new messages