Shop OBEX P1 Docs P2 Docs Learn Events
quick question about the or function — Parallax Forums

quick question about the or function

ArchiverArchiver Posts: 46,084
edited 2001-10-12 22:32 in General Discussion
I would like to know what is the correct way to use the "or " function on the
basic stamp... what i trying to do is OR three inputs it must link to
another part of the program if only an only if the three inputs ored
togeether is equal to 1.... Is the code list on the bottom correct....

Check_SW
If input1= 0 then time_20
if input2= 0 then time_45
if input3= 0 then time_60
if input1|input2|input3= 1 then un_lock


Thank you wendell


[noparse][[/noparse]Non-text portions of this message have been removed]

Comments

  • ArchiverArchiver Posts: 46,084
    edited 2001-10-11 22:21
    >another part of the program if only an only if the three inputs ored
    >togeether is equal to 1.... Is the code list on the bottom correct....

    > if input1|input2|input3= 1 then un_lock

    What you need here is the "AND" function.

    Carl
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-11 22:26
    At 05:21 PM 10/11/01 -0400, you wrote:
    > >another part of the program if only an only if the three inputs ored
    > >togeether is equal to 1.... Is the code list on the bottom correct....
    >
    > > if input1|input2|input3= 1 then un_lock
    >
    >What you need here is the "AND" function.
    >
    >Carl

    No, OR is what he wants...

    OR AND
    000 skip to next Line skip to next Line
    001 goto un_lock skip to next Line
    010 goto un_lock skip to next Line
    011 goto un_lock skip to next Line
    100 goto un_lock skip to next Line
    101 goto un_lock skip to next Line
    110 goto un_lock skip to next Line
    111 goto un_lock goto un_lock

    "OR" he could simply use addition...

    if input1+input2+input3 > 0 then un_lock


    Beau Schwabe IC Mask Designer
    National Semiconductor Wired Communications Division
    500 Pinnacle Court, Suite 525 Mail Stop GA1 Norcross, GA 30071
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-12 12:16
    >At 05:21 PM 10/11/01 -0400, you wrote:
    >> >another part of the program if only an only if the three inputs ored
    >> >togeether is equal to 1.... Is the code list on the bottom correct....
    >>
    >> > if input1|input2|input3= 1 then un_lock
    >>
    >>What you need here is the "AND" function.
    >>
    >>Carl
    >
    >No, OR is what he wants...
    >
    > OR AND
    >000 skip to next Line skip to next Line
    >001 goto un_lock skip to next Line
    >010 goto un_lock skip to next Line
    >011 goto un_lock skip to next Line
    >100 goto un_lock skip to next Line
    >101 goto un_lock skip to next Line
    >110 goto un_lock skip to next Line
    >111 goto un_lock goto un_lock
    >
    >"OR" he could simply use addition...
    >
    >if input1+input2+input3 > 0 then un_lock
    >
    Original post:
    :another part of the program if only an only if the three inputs ored
    :togeether is equal to 1.... Is the code list on the bottom correct....
    :Check_SW
    : If input1= 0 then time_20 ; 0 1 1
    : if input2= 0 then time_45 ; 1 0 1
    : if input3= 0 then time_60 ; 1 1 0
    : if input1|input2|input3= 1 then un_lock ; 1 1 1


    With "OR", any 1 input is 1. Since he specified that he needed all
    three = 1, that's and "AND". Actually, since he is testing for four
    conditions out of a possible 16, he needs to specify the state of
    each input for each of his conditional lines. What if the switches
    read "0 0 1"?
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-12 14:53
    At 07:16 AM 10/12/01 -0400, you wrote:
    > >At 05:21 PM 10/11/01 -0400, you wrote:
    > >> >another part of the program if only an only if the three inputs ored
    > >> >togeether is equal to 1.... Is the code list on the bottom correct....
    > >>
    > >> > if input1|input2|input3= 1 then un_lock
    > >>
    > >>What you need here is the "AND" function.
    > >>
    > >>Carl
    > >
    > >No, OR is what he wants...
    > >
    > > OR AND
    > >000 skip to next Line skip to next Line
    > >001 goto un_lock skip to next Line
    > >010 goto un_lock skip to next Line
    > >011 goto un_lock skip to next Line
    > >100 goto un_lock skip to next Line
    > >101 goto un_lock skip to next Line
    > >110 goto un_lock skip to next Line
    > >111 goto un_lock goto un_lock
    > >
    > >"OR" he could simply use addition...
    > >
    > >if input1+input2+input3 > 0 then un_lock
    > >
    >Original post:
    >:another part of the program if only an only if the three inputs ored
    >:togeether is equal to 1.... Is the code list on the bottom correct....
    >:Check_SW
    >: If input1= 0 then time_20 ; 0 1 1
    >: if input2= 0 then time_45 ; 1 0 1
    >: if input3= 0 then time_60 ; 1 1 0
    >: if input1|input2|input3= 1 then un_lock ; 1 1 1
    >
    >
    >With "OR", any 1 input is 1. Since he specified that he needed all
    >three = 1, that's and "AND". Actually, since he is testing for four
    >conditions out of a possible 16, he needs to specify the state of
    >each input for each of his conditional lines. What if the switches
    >read "0 0 1"?


    "ored", that would be 1

    "AND" would result in a 0


    I just don't see where you are reading that "he specified that he needed
    all three = 1" (<--Quote from you), instead what I see in his original
    post is...

    "if only an only if the three inputs ored togeether is equal to 1"

    ...the key word being "ored"


    Beau Schwabe IC Mask Designer
    National Semiconductor Wired Communications Division
    500 Pinnacle Court, Suite 525 Mail Stop GA1 Norcross, GA 30071
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-12 16:51
    Wendell -

    This has caused much confusion. However, let's look at your code with
    some comments added:

    Check_SW
    If input1= 0 then time_20 ' if we pass here, input1 == 1
    if input2= 0 then time_45 ' if we pass here, input2 == 1
    if input3= 0 then time_60 ' if we pass here, input3 == 1, so...
    if input1|input2|input3= 1 then un_lock ' the only time we can
    ' be here is if all 3
    ' inputs are at 1.

    What we are describing in the fourth "if" statement would call for an
    AND, e.g. "if input1 = 1 AND input2 = 1 AND input3 = 1 THEN un_lock".
    However, if we get to this point, we already know that the three-
    input AND statement in my last sentence is true. So you could replace
    the foursth "if" statement with "goto unlock". Standing by itself, it
    would go true if at least one of the inputs equal 1, but since we
    have already tested all 3 for 0 equality and found it false, we know
    all 3 are 1, so we do not need a fourth "if" test. Otherwise we could
    have fun with truth tables.

    Bob Pence



    --- In basicstamps@y..., ARTICALEX@A... wrote:


    > I would like to know what is the correct way to use the "or "
    function on the
    > basic stamp... what i trying to do is OR three inputs it must
    link to
    > another part of the program if only an only if the three inputs
    ored
    > togeether is equal to 1.... Is the code list on the bottom
    correct....
    >
    > Check_SW
    > If input1= 0 then time_20
    > if input2= 0 then time_45
    > if input3= 0 then time_60
    > if input1|input2|input3= 1 then un_lock
    >
    >
    > Thank you wendell
    >
    >
    > [noparse][[/noparse]Non-text portions of this message have been removed]
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-12 21:45
    I didn't mean to add to the confusion, but since Wendell's program
    wasn't working correctly to begin with... hence why he asked a
    question. I was responding more to what he was saying, rather
    than the code snip that he provided.



    >Wendell -
    >
    >This has caused much confusion. However, let's look at your code with
    >some comments added:
    >
    >Check_SW
    > If input1= 0 then time_20 ' if we pass here, input1 == 1
    > if input2= 0 then time_45 ' if we pass here, input2 == 1
    > if input3= 0 then time_60 ' if we pass here, input3 == 1, so...
    > if input1|input2|input3= 1 then un_lock ' the only time we can
    > ' be here is if all 3
    > ' inputs are at 1.
    >
    >What we are describing in the fourth "if" statement would call for an
    >AND, e.g. "if input1 = 1 AND input2 = 1 AND input3 = 1 THEN un_lock".
    >However, if we get to this point, we already know that the three-
    >input AND statement in my last sentence is true. So you could replace
    >the foursth "if" statement with "goto unlock". Standing by itself, it
    >would go true if at least one of the inputs equal 1, but since we
    >have already tested all 3 for 0 equality and found it false, we know
    >all 3 are 1, so we do not need a fourth "if" test. Otherwise we could
    >have fun with truth tables.
    >
    >Bob Pence
    >
    >
    >
    >--- In basicstamps@y..., ARTICALEX@A... wrote:
    >
    >
    > > I would like to know what is the correct way to use the "or "
    >function on the
    > > basic stamp... what i trying to do is OR three inputs it must
    >link to
    > > another part of the program if only an only if the three inputs
    >ored
    > > togeether is equal to 1.... Is the code list on the bottom
    >correct....
    > >
    > > Check_SW
    > > If input1= 0 then time_20
    > > if input2= 0 then time_45
    > > if input3= 0 then time_60
    > > if input1|input2|input3= 1 then un_lock
    > >
    > >
    > > Thank you wendell
    > >
    > >
    > > [noparse][[/noparse]Non-text portions of this message have been removed]

    Beau Schwabe IC Mask Designer
    National Semiconductor Wired Communications Division
    500 Pinnacle Court, Suite 525 Mail Stop GA1 Norcross, GA 30071
  • ArchiverArchiver Posts: 46,084
    edited 2001-10-12 22:32
    >
    >I just don't see where you are reading that "he specified that he needed
    >all three = 1" (<--Quote from you), instead what I see in his original
    >post is...
    >
    >"if only an only if the three inputs ored togeether is equal to 1"
    >
    >...the key word being "ored"
    >
    *My* keyword is "three". Perhaps ARTICALEX@A... could refine
    his specs a bit.
Sign In or Register to comment.