Discussion about the ZBasic language including the System Library. If you're not sure where to post your message, do it here. However, do not make test posts here; that's the purpose of the Sandbox.
I am FINALLY, after a LONG hiatus getting back to a project. It is some software to interface to an IEEE-488 (GPIB) bus. As usual, It is MUCH MUCH easier to do development in ZBasic rather than C/Arduino.
In the documentation of PinRead() it says
a non-zero return value indicates a logic high
Is this return value always a "1" or is it some other non-zero value from time to time? Under what circumstances might a high value be represented by something other than a "1"?
spamiam wrote:Under what circumstances might a high value be represented by something other than a "1"?
The return value is produced by ANDing a mask value having but one bit asserted with the value obtained by reading the PIN register containing the specified pin. Consequently, the non-zero return value will equal the mask value.
This may be more clear by examining the code produced for this simple program:
It is not a problem. It is easy to use "<> 0" instead of "= 1". I do not know the assembly language options, but it may be faster to compare to zero than to a non-zero number where the non-zero argument number may need to be loaded into a register for comparison.
I will adjust my code accordingly.
In some cases the "<>0 comparison will work well. But other times, I will compare against a variable which will be High or Low, and the IIF() statement is does the job nicely.