Structure Arrays
jjames
AMX Sustaining Engineer
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?
Comments
-
Yes you can. Here is an example of the syntax:
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'jjames wrote: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: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? -
Structure: can we build it? Yes we can!
-
Thank you much! Works like a charm.
-
It's magically delicious.jjames wrote:Thank you much! Works like a charm.
-
jjames wrote:Is it possible to have a structure array? (Structures within structures.) I can't get it to compile. Grrr - this would be very helpful.
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. -
GSLogic wrote:You can also have multi dimension arrays inside the structure.
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. -
Here is an array of structures. This may be a simple version of what you were looking for. Of course you can have any variable inside CHAR, INT, INT[][].
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
Categories
- All Categories
- 2.5K AMX General Discussion
- 922 AMX Technical Discussion
- 514 AMX Hardware
- 502 AMX Control Products
- 3 AMX Video Distribution Products
- 9 AMX Networked AV (SVSI) Products
- AMX Workspace & Collaboration Products
- 3.4K AMX Software
- 151 AMX Resource Management Suite Software
- 386 AMX Design Tools
- 2.4K NetLinx Studio
- 135 Duet/Cafe Duet
- 248 NetLinx Modules & Duet Modules
- 57 AMX RPM Forum
- 228 MODPEDIA - The Public Repository of Modules for Everyone
- 943 AMX Specialty Forums
- 2.6K AMXForums Archive
- 2.6K AMXForums Archive Threads
- 1.5K AMX Hardware
- 432 AMX Applications and Solutions
- 249 Residential Forum
- 182 Tips and Tricks
- 146 AMX Website/Forums