Ok, so to be clear. I may (or may not) have taught Nick a thing or three about ‘Opto’, but he taught me a great deal about programming in OptoScript. I’m sure Nick remembers the many times I told him how I was flat out scared of the stuff.
Its also probably my fault for Nicks first goes at checking for the exact value of -1. I simply did not know any better!
Im still not super fond of it, but Mary has picked up where Nick left off and has been dragging me kicking and screaming into the world of OptoScript.
I mention that because it is different if you are not used it, but here we are years down the track, and I find myself dumping an OptoScipt block right after ‘Block 0’ in pretty much every chart I write these days…
So, that said, this whats-true-whats-false-and-how-to-test-for-it still trips me up a bit…
I like and use this method a fair bit to do stuff if a variable is true;
if (digitalIN) then
do stuff if the point is on
Its clean and efficient. Of course it does not have to just be a digital in:
if ((digitalIN) and (someVAR)) then
do stuff if both the digital in and the var are true
Is there an advantage or disadvantage from doing this way vs the way Nick said?
(No offense Nick, but the whole <>0 trips me up when I am reading it because I see the zero, and I think the var has to be zero to do the do… I still have trouble thinking in reverse after all these years!).
Ok, so that’s true, but what about not true?
We can do this pretty quick and clean:
if (not(digitalIN)) then
do stuff if the point is off
But is simply putting ‘not’ in front the best way to ‘read’ your code?
Im not the best typist, so I need it quick to bang out, and the whole ‘isVariableTrue’ or isVariableFalse’ is just too much work for my fingers (and brain).
I just want to know the best way to check for true and false that is easy to type and easy to read.
P.S Really enjoying this ‘how to program 101’ thread!