PDA

View Full Version : Help needed to define arrays of structures


HARRY01
12-05-2006, 09:17 AM
I need to create an array of structures which contain an array of structures. In fact I port a piece of code from Visual Basic to PPL.

In Visual basic it looks like:

Type Cell
x as integer
y as integer
v as integer
End type

Type mpmline
nr as integer
cdata (1 to 9) as Cell
End type

Global mpm (1 to 9) as mpmline

The definition (1 to 9) is not possible, I think. So make it 10 elements, then I will not use element 0.

Grateful as always for some help.

Harry

Richard
12-05-2006, 09:43 AM
Try this:

#DEFINE Cell ("x","y","z")

global (mpmline$);
struct (mpmline$,Cell); // Set the global structure
TDim (mpmline$,10); // Allocate 10 items (0 to 9)

This will give you an array of structures, but not the array within an array that you wanted. (I use this technique in my keyboard logic)

If you are using a fixed size for the array, convert it to a single array of 9 times 9 entries.

Or you could possibly define "x1" to "x9", "y1" to "y9" etc. for each.

Or easiest of all simply save your x,y,z data as a delimited string in a two dimentional array.

There are many ways to do this in PPL, just not the same as the VB way :(

Richard.