> Van: PHXSYS > Aan: PICLIST@MITVMA.MIT.EDU > Onderwerp: Whats the difference between IF true and NOT > Datum: vrijdag 8 mei 1998 5:59 > > Hello > > According to the stamp manual page 274, if I understand it you can write an > If...then statement like: > > Flag var byte > Flag = 1 > > If flag then istrue 'Value is true- True is any value other than 0 > and > If NOT flag then istrue 'Is also true > > Isn't NOT 1 the same as 0 or 2...any non 0 number. If true is any value other > than 0 and "NOT 1 is true" as well as any non-zero numberI don't understand > the difference. > > For example whats the difference between these two commands > > IF NOT in1 then si2c_rbyte_dl > and > IF bit_count then si2c_rbyte_lp > > > Thanks > > Jon Try to look at it this way : True & False are _logical_ variables (1 Bit wide). You can represent them as you like, as is done here : 0 == True, all other values are False. So, first convert your register-value (256 states, 0 thru 255) to a Logical state (2 states, True or False) Now let's look at your question : if then If is 0 it is True and the will be taken. If contains anything else it will not. Now the next : if NOT then If is 0 it is True. This will be _logically_ inverted (NOT). This makes the result False. The will _not_ be taken. If is not equal to 0 it is False. Invert it and you get True. The will be taken ... The example 'IF bit_count then si2c_rbyte_lp' is dirty piece of code. Why ? because we use a register that should hold only 2-state's (True & False) as a counter (256 states for Byte-counter). It works fine because if the counter == 0 it will _logically_ be equal to a True. If the counter is anything else than a 0 it will, again logically, be equal to a False. Greetz, Rudy Wieser