arrayItem Issue


1) Give a description of the problem
I have a device named devs that has 6 devices in it. I want to use a FOR statement with arrayItem to individually get the power for each device by using arrayItem by doing this in an expression of a condition in an IF statement:


but when I do that, I get an error message. See the attached screen capture. If I replace arrayItem($index,devs) with a device name, then the condition works. Do I need to somehow declare arrayItem($index,devs) to be a device for which I can get :power?

2) What is the expected behaviour?
interpret arrayItem($index,devs) to be a device

3) What is happening/not happening?
I get an error message.

4) Post a Green Snapshot of the pistonimage

Here is the device declaration:


5) Attach logs after turning logging level to Full
No logs. Webcore will not compile that statement because of the error.


Instead of arrayItem, have you tried just iterating like below…

for each ($device in devs)
  log to console [$device:power]
end for each


Well, I could do that if all I wanted to do was access that dev list. But I need an index value so that I can index into a 2nd list of devices based on the criteria for the 1st. Here’s an pseudo example:

For index from 0 to 5 step 1
if {[devlist1(index):power]} is <10 then
if {[devlist2(index):switch]} is ON then
do something
next index


I will have a look.

Another choice is to assign the arrayItem(RRindex,devs) to another device variable, then use that for your attribute evaluation


Thanks for that suggestion. It works great!