gotta be a typo somewhere...
vegastech
Posts: 369
I am using variables to change the state of my shades, proj lift, and screen buttons. Unfortunately, however, the state is not changing when the variable changes. I have another button, call it status, that does change states:
code]
DEFINE_PROGRAM
[dvCV7Tp,100] = (nShadeOpen == 1)
[dvCV7Tp,101] = (nShadeOpen == 0)
[dvCV7Tp,102] = (nLiftOpen == 1)
[dvCV7Tp,103] = (nLiftOpen == 0)
[dvCV7Tp,104] = (nScreenOpen == 1)
[dvCV7Tp,105] = (nScreenOpen == 0)
[dvCV7Tp,106] = (nShadeOpen == 1 && nScreenOpen == 1 && nLiftOpen == 1) //This is status
[/code]
Can someone point me in the right direction?
code]
DEFINE_PROGRAM
[dvCV7Tp,100] = (nShadeOpen == 1)
[dvCV7Tp,101] = (nShadeOpen == 0)
[dvCV7Tp,102] = (nLiftOpen == 1)
[dvCV7Tp,103] = (nLiftOpen == 0)
[dvCV7Tp,104] = (nScreenOpen == 1)
[dvCV7Tp,105] = (nScreenOpen == 0)
[dvCV7Tp,106] = (nShadeOpen == 1 && nScreenOpen == 1 && nLiftOpen == 1) //This is status
[/code]
Can someone point me in the right direction?
0
Comments
Joking... A common mistake I have done a couple of times. In TP Design, make sure the feedback is set on channel.
Making the following assumption: Your variables only go zero or one. (no two or whatever.)
you don't need the parens.
[dvCV7Tp,100] = nShadeOpen
[dvCV7Tp,101] = !nShadeOpen // !=NOT
[dvCV7Tp,102] = nLiftOpen
[dvCV7Tp,103] = !nLiftOpen // !=NOT
additionally, I'd probably put these inside a wait so they're not evaluated every DEFINE_PROGRAM pass.
WAIT 8
{
[dvCV7Tp,100] = nShadeOpen
[dvCV7Tp,101] = !nShadeOpen // !=NOT
[dvCV7Tp,102] = nLiftOpen
[dvCV7Tp,103] = !nLiftOpen // !=NOT
} // END WAIT 8
It's not that big a deal, however
I don't think it matters in NetLinx. I believe that 0 = false and any non-0 = true. If I get a chance, I will verify this, but I am pretty sure that I have some if() statements that evaluate based on that thought and I would be getting some occasional odd errors if that wasn't true... which means I need to verify this to make sure I don't have the potential for odd errors
Jeff
I will do a little test in the morning to verify and post the results.
Jeff
But, my advice always come with the disclaimer of possible wrongness anyway. You get what you pay for.
here are the results:
As is illustrated by the last example, the keyword TRUE does not encapsulate all values that will evaluate to true
Jeff
P.S.
I understand what you are saying now Eric.
I don't think my bosses have said that EVER! you just made my day. Thanks!
Boy do I know that feeling. Glad I could help
Jeff
I've also had some very inexplicable cases where an implicit comparison didn't work, but an explicit one did. For example, something like IF(!bRandomVar) didn't do what I expected, but, IF(bRandomVar == FALSE) did. I tend to use the implicit form most all the time, but when I get one of those oddball cases, I just add the == to it and move on. I never troubled to figure out why it happens.
Same here. I almost always now use actual comparisons. I also no longer use the "<>" nor the words AND, OR, etc. It does to me make it easier. Parenthesis I know aren't needed, but it's never bad to be too safe, is it? (I also use the colon to end my lines as well now. Perhaps it's just cuz I've been dabling with other languages, and it feels right to do it in NetLinx.)
When has this every stopped us from rumbling on for miles? We are the 'coal train' of forums. It takes us a tremendouly long time to stop.