Shop OBEX P1 Docs P2 Docs Learn Events
Using and or for comparassion Help — Parallax Forums

Using and or for comparassion Help

Jeff_5_Jeff_5_ Posts: 36
edited 2010-08-06 07:04 in BASIC Stamp
i declare

buf VAR Word
word1 VAR Word
word2 VAR Word
word3 VAR Word

Read a value in to buf then want to compare them.

If(buf <> word1) & (buf <> word2) Then

word3=buf

The problem is it wont do both comparisons with the & symbol how can i make this work?

I have the same problem with the OR |

If(buf = word1) | (buf = word2) Then
High enable

It wont do the compassion with the OR symbol between the two

Post Edited (Jeff_5_) : 8/6/2010 12:26:16 AM GMT

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-08-06 07:04
    & and | are bit operations. They do logical AND and OR bit by bit on the 16 bit values involved. What you want to use are the AND and OR operators like

    IF (buf <> word1) AND (buf <> word2) THEN
Sign In or Register to comment.