Multi dimensional DEV Array?
troberts
Posts: 228
Hey just wondering if it is possible to create a multi-dimensional DEV array. In my DEFINE_VARIABLE section I usually do this:
VOLATILE
DEV dvMRA_SOURCES[] = {dvDSS1,dvDSS2,vdvKSCAPE}
but I would like to add another dimension to it, just not sure how to do it or if it is possible
VOLATILE
DEV dvMRA_SOURCES[nROOM1][] = {dvDSS1,dvDSS2,vdvKSCAPE}
VOLATILE
DEV dvMRA_SOURCES[] = {dvDSS1,dvDSS2,vdvKSCAPE}
but I would like to add another dimension to it, just not sure how to do it or if it is possible
VOLATILE
DEV dvMRA_SOURCES[nROOM1][] = {dvDSS1,dvDSS2,vdvKSCAPE}
0
Comments
I was starting to think that too. I just wrote a function to accomplish what I was wanting to do...I think it will work fine. But if someone knows how or if its possible to do a multi dimensional DEV array, please let us know.
Thanks
I'll expand on your example just a little bit.
This isn't how I would normally set things up, but it follows how you were already storing your room's sources. I normally have a separate structure for my sources with names, control type, audio switch input, video switch input, device definition, and source type. Then I can reference that will a simple index.
You could do that pretty easily with my example above by moving the sources to their own structure and changing the _rooms structure to put a simple integer availableSources[10] instead of nesting the source structure within it. Then you use the room integer array as pointers to the source structure.
There are thousands of ways to structure your data and I have shown you only two, but I will say learning and living by structures makes code more modular and easier to read for me.
I always use structures as well, but never thought of setting them up for DEVs and sources like that. I likey
You can certainly use multi dimensional arrays of devices. I can see certain applications that that would be very handy. However, its almost always less complex to just store an integer that represents an index to an array of devices but it would depend on the application. If you had a 4x4 wall of TVs you needed to send commands to, you could do something like send_command dvTVs[1][2], "'PowerOn'".
Paul