Current Array Status
Small
Posts: 9
Hi,
Hope someone can help me here, or at least tell me what I am trying to do is not possible. I've scoured the forum, but found nothing to help.
I am using an array to determine the current open/closed status of 6 room partitions:
INTEGER PART_ARRAY[6] //1 or 0 to state open or closed
INTEGER PANEL_ARRAY[5] //1 or 0 to state which panels in use
All I want to do is read the current status so I can set which slave panels are in use. I assumed the following to work fine, but unfortunately does not:
IF (PART_ARRAY[] = {0,1,1,1,1,1})
{
MASTER_ARRAY[] = {1,0,1,1,1}
}
Can anyone offer any solution to stop my hair falling out.
Much appreciated,
Paul
Hope someone can help me here, or at least tell me what I am trying to do is not possible. I've scoured the forum, but found nothing to help.
I am using an array to determine the current open/closed status of 6 room partitions:
INTEGER PART_ARRAY[6] //1 or 0 to state open or closed
INTEGER PANEL_ARRAY[5] //1 or 0 to state which panels in use
All I want to do is read the current status so I can set which slave panels are in use. I assumed the following to work fine, but unfortunately does not:
IF (PART_ARRAY[] = {0,1,1,1,1,1})
{
MASTER_ARRAY[] = {1,0,1,1,1}
}
Can anyone offer any solution to stop my hair falling out.
Much appreciated,
Paul
0
Comments
My guess is that if you run 'MSG ON ALL' in terminal you'll see a 'zero index' error when the line runs. Hope that help
e
IF ((!PART_ARRAY[1])&(PART_ARRAY[2])&(PART_ARRAY[3])&(PART_ARRAY[4])&(PART_ARRAY[5])&(PART_ARRAY[6]))
{
MASTER_ARRAY[1]=1
MASTER_ARRAY[2]=0
MASTER_ARRAY[3]=1
MASTER_ARRAY[4]=1
MASTER_ARRAY[5]=1
}
I assumed would work fine as:
IF(PART_ARRAY[]={0,1,1,1,1,1}) MASTER_ARRAY[]={1,0,1,1,1}
or:
IF(PART_ARRAY={0,1,1,1,1,1}) MASTER_ARRAY={1,0,1,1,1}
But unfortunately does not.
If it can't be done, I'll just have to do it the long way
But now that you mention it - I am not sure that I know how to setup that statement with out doing multiple ifs and &&.
have you tried
if(PART_ARRAY = (1,1,1,0,0)) no square brackets no curley brakets? (for the reason that Eric mentioned previously)
if(PART_ARRAY = "1,1,1,0,0"), etc.
Here is a quick attempt at a function:
But, it seems that Dave's code will do what you want
Jeff
Quality, thanks for that. That sorts out the first part, but unfortunately doesn't work when trying to set the second arrays contents, i.e:
IF (PART_ARRAY = "1,1,1,0,0") // WORKS FINE
{
MASTER_ARRAY="0,0,1,0,1" // Does not work. Sees as string.
MASTER_ARRAY={0,0,1,0,1} // Also, does not work.
MASTER_ARRAY=(0,0,1,0,1) // Also, does not work.
}
Any ideas?
A CHAR variable is actually an 8-bit integer and you can use CHAR variables as flags and such so long as you pay attention. If you do, then such things as
MASTER_ARRAY="0,0,1,0,1"
will work just fine.
Cheers,
Paul
This also allows you to easily see if any zone is on (if(PART_STATUS) send_string 0,"'Atleast one zone is ON'")
Jeff