Folks, A newbe question, but I'm trying to figure out how to use variable arrays (i,j) and variable structures.
I have a large number of leak sensors, each with many variables, some of which are changed by the device actions and some by code. I'd rather be able to loop through these using an array of structures than explicitly add and delete code for every new/removed sensor; that becomes a maintenance nightmare quickly.
Any sample would be greatly appreciated., along with any documentation references (couldn't find any). If it turns out it can NOT be done (hard to imagine), what are some work-arounds?
I'm just using pseudo code in the example, but here is a rough idea of my thoughts
DEFINE STRUCTURE strLeakDetector
.location as string
.state as string
.lastHeartBeat as dateTime
END STRUCTURE
DEFINE ARRAY aryLeakDetector strLeakDetector(24)
(set values for aryLeakDetector)....
And be able to use code that would not change with the addition or deletion of a device, such as:
FOR i = 1 to aryLeakDetector.count
IF aryLeakDetector(i).state = ON then
(set a leakDetectedFlag = TRUE)
EXIT FOR
END IF
(set leakDetectedFlag = FALSE)
END FOR
thanks - russg