Structure Arrays
jjames
Posts: 2,908
Is it possible to have a structure array? (Structures within structures.) I can't get it to compile. Grrr - this would be very helpful.
Ex:
Perhaps what I'm trying to accomplish is done another way?
Ex:
STRUCTURE struct_1
{
CHAR Name[70]
INTEGER Number
}
STRUCTURE struct_2
{
CHAR Name[70]
INTEGER Number
}
STRUCTURE struct_3
{
CHAR Name[70]
INTEGER Number
}
STRUCTURE struct_4
{
CHAR Name[70]
INTEGER Number
}
STRUCTURE struct_All[]
{
struct_1
,struct_2
,struct_3
,struct_4
}
Perhaps what I'm trying to accomplish is done another way?
0
Comments
DEFINE_TYPE STRUCTURE struct_1 { CHAR Name[70] INTEGER Number } STRUCTURE struct_2 { CHAR Name[70] INTEGER Number } STRUCTURE struct_3 { CHAR Name[70] INTEGER Number } STRUCTURE struct_4 { CHAR Name[70] INTEGER Number } STRUCTURE struct_All { struct_1 somename1 struct_2 somename2 struct_3 somename3[4] struct_4 somename4 } DEFINE_VARIABLE struct_All all_structs[5] DEFINE_START all_structs[1].somename1.Name = 'what' all_structs[1].somename3[3].Name = 'ever'You can also have multi dimension arrays inside the structure.
//************************** STRUCTURE _test { char strName[4][70]; integer nNumber[4]; } //*************************** DEFINE_VARIABLE _test test[4] //*************************** DEFINE_START test[1].strName[1] = 'slot one array one'; test[1].nNumber[1] = 1; test[2].strName[3] = 'slot three array two'; test[2].nNumber[3] = 3;Just another way to look at it.
Hmmm - I might like this one just a tad better. I can then set up constants instead of trying to remember what test[1] or test[5] is.
PROGRAM_NAME='TestStruct' DEFINE_TYPE STRUCTURE _sStuct_Define { CHAR cVar1[50] // CHAR cVar2[255] // CHAR cVar3[50] // INTEGER iVar1 // INTEGER iVar2 // } DEFINE_VARIABLE _sStuct_Define struct1 _sStuct_Define struct2 _sStuct_Define struct3 _sStuct_Define struct4 _sStuct_Define struct5 _sStuct_Define structAll[5] DEFINE_START structAll[1] = struct1 structAll[2] = struct2 structAll[3] = struct3 structAll[4] = struct4 structAll[5] = struct5