Shop OBEX P1 Docs P2 Docs Learn Events
A programming question — Parallax Forums

A programming question

cedtinsicedtinsi Posts: 45
edited 2011-03-09 07:38 in BASIC Stamp
Thank You and Welcome.

I have a programming concern.

Can I use multiple conjonctions in a statement?

I mean something like:

DO
LOOP UNTIL (IN1=1)OR (IN2=1)OR (IN3=1)OR (IN4=1)

Can the Basic Stamp read and execute that?

Please, as always, your help will be appreciated.
Thanks.

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-03-09 05:00
    Yes, please see the STAMP manual for basic syntax questions.
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    i VAR Byte
    
    MAIN:
    i=0
    DO
      DEBUG "Hello World"
      i=1
    LOOP UNTIL ((i=1) OR (i=2))
    END
    
  • cedtinsicedtinsi Posts: 45
    edited 2011-03-09 06:00
    First, Thank you for your help Sir.

    I consulted the Basic Stamp Manual before asking the question.
    I am sorry for any misunderstanding; but my question is: can I use multiple OR's or AND's in a conditional statement?
    I mean, more than one OR or one AND; what is the maximum I can use?

    {$STAMPBS2}
    {$PBASIC 2.5}

    i VAR Byte

    Do
    i=i+1
    DEBUG " * "
    LOOP UNTIL ((i=1) OR (i=2) OR (i=3) OR (i=4))

    can I do that?


    Again, thank you.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-03-09 07:00
    Yes, you can do that. The maximum number, for practical purposes, is unlimited. Keep in mind that each term (like "OR i=4") takes some BS2 memory and that is the limiting factor. Also, the entire expression is evaluated before the UNTIL is executed. If you have a lot of terms, this can slow your program down.
  • cedtinsicedtinsi Posts: 45
    edited 2011-03-09 07:38
    Thank you Mr. Green.




    This forum is amazing!


    Assistance for free!!!

    Thank you to all of you.
    Anyone who reads this, is making it possible.

    thanks.
Sign In or Register to comment.