I am trying to use three x if statements, without an else.
I seem to be struggling though. I think I probably ought to be using elseif but not sure how.
My 2xflow variables are set to 0 in a separate function node.
Can anyone offer assitance?
//declare state and count variable
var state = flow.get("redstate21");
var count = flow.get("redcount21");
//check to see that state has not changed
If(msg.payload = state)
{
msg.payload = count;
}
//if payload is 0 and state was 1, do nothing
If(msg.payload < state)
flow.set('redstate21', 0)
{
msg.payload = count;
}
//if payload is 1 but state was 0, increase count by 1
If(msg.payload > state)
{
//increase the count by 1
msg.payload = count+1
//increase the flow,redcount21 variable by 1
flow.set('redcount21', count);
// record current state
flow.set('redstate21', 1)
}
return msg;