Structures within structures
Hi, can someone link me to a resource that can explain this? I can post more detail as to what's confusing me but if there's a good link I can just check that out to start.
Thanks
Answers
-
Maybe not the most useful but...
structure _time { integer hours; integer minutes; integer seconds } structure _date { integer day; integer month; integer year; } structure _timeStamp { _time time; _date date; } volatile _timeStamp uTimeStamp; uTimeStamp.time.hours = time_to_hour(time); -
Cool thanks
-
If you go too big and too deep nesting structures you might not enjoying watching them in debug. If you try to mimic deep jason or xml nests debug can really suck.
-
Also you can't use Variable_To_XML on nested structures, it breaks and corrupts the XML.
-
I believe there is (or used to be) a hard limit on structure depth, like 5 deep or something like that? I've gone past it.
-
I'm still lost. Any other links available?
-
What is your application or what are you having dufficulty with so we can provide more relevant help.
-
Since I ended up copying and pasting some code anyway, I'll post a simplified version of the structures I use to store room and device data...
(***********************************************************)
(* DATA TYPE DEFINITIONS GO BELOW *)
(***********************************************************)
structure deviceip {
char name[32]
char ipaddr[20]
integer ipport
integer iptype
dev devid
}
structure displaysettings {
char name[32]
integer type
dev devid
dev vdvdevid
integer commtype
deviceip ipcomm[1] //THIS IS PUTTING THE STRUCTURE ABOVE INTO THIS STRUCTURE
char sercomm[64]
integer pwr
integer vmute
integer feed
integer follows
integer status
integer swtid //VGA Switch ID
char vport[16] //VGA Port Number
integer chan
integer amute
integer vol
integer volset
integer tmp
integer ipconnect
integer ipdone
integer init
char text[32]
char buffout[1024] //holds buffer of integer commands as string data for fifo operations
char buffin[512]
char lastacmd[512]
integer lastcmd
}
structure audchans {
char name[20]
integer unit
integer id
integer chan
integer val
integer mute
integer volset
}
structure audiodata {
char name[32]
integer type
integer init
char sernum[16]
audchans ch[30] //THIS PUTS THE AUDIOCHANNELS ABOVE INTO THIS STRUCTURE
}
structure inputs {
char name[32]
integer swtid //VGA Switch ID
char vport[16] //HDMI Switch Video Port (nornally Aud and Vid)
char aport[16] //HDMI Switch Audio Port (Use separate Aud/Vid for oddball stuff)
integer follows
}
//THIS IS THE MAIN, TOP-LEVEL STRUCTURE:
structure room {
char name[32]
char dbid[12]
integer status
displaysettings d[21] //PUTS DISPLAY STRUCTURE (WITH IP SUB_STRUCTURE) IN THIS STRUCTURE
audiodata audio[1] //PUTS AUDIO DATA STRUCTURE & SUB_STRUCTURES INTO THIS STRUCTURE
inputs in[16] //PUTS INPUT DATA STRUCTURE INTO THIS STRUCTURE
helpdata help[1]
}...then all I have to do to define the whole structure and sub-structure
(***********************************************************)
(* VARIABLE DEFINITIONS GO BELOW *)
(***********************************************************)
DEFINE_VARIABLE
persistent room rm[2] //THIS DEFINES TWO ROOMS with all the data cells of the sub-structures underneath themThen to get to any cell in the structure:
stored_volume = rm[this_rm].d[this_device].a[1].ch[this_ch].val...hope that helps if you're still struggling with building and using structures.
-
@JasonS said:
Also you can't use Variable_To_XML on nested structures, it breaks and corrupts the XML.This is not true, we write nested structures to XML all the time. In some cases up to 5 levels.
-
@mush Could you post an example of the code that writes the structure to disk? On an NX or NI processor?
-
I use variable to string and string to variable to pass updated structures, a single level, from modules back to the main all the time and use variable to xml to store data on the flash that are 3 levels deep. I've never noticed corrupted data but to be honest I haven't looked for it either.
-
Thanks everyone I figured it out.
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

