Shop OBEX P1 Docs P2 Docs Learn Events
Loop Never ? — Parallax Forums

Loop Never ?

SamTheManSamTheMan Posts: 43
edited 2007-06-19 20:02 in General Discussion
LOOP NEVER
What do I use this command in/for?
I checked the assembly code and I found it completely empty from any commands!
It just defined two labels without any commands.

Comments

  • BeanBean Posts: 8,129
    edited 2007-06-19 11:23
    It is used to make an IF...OR constuction.

    Let's say you wanted to do something if (A = 1) OR (B = 2)

    You would use

    DO
    · IF A <> 1 THEN
    ··· IF B <> 2 THEN EXIT
    · ENDIF
    · ' Do whatever here
    LOOP NEVER

    Notice that must use the opposite condition in the IF statements (<> instead of =).

    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2007-06-19 16:25
    Bean.


    DO
    · IF A <> 1 THEN

    ·IF B <> 2 THEN EXIT

    Is to mean that if A and B are not( "="· to 1 OR 2 ) then it will Not Loop
    and only goto ' Do whatever here but is that what the EXIT Dose

    Or is to mean that it only loop ONE TIME

    ·' Do whatever here
    ·

    LOOP NEVER

    I am not understanding what This Means LOOP NEVER

    What dose the NEVER tell it to do· or look for

    I understand what·LOOP means and what it dose
    I understand what· <> means NOT = to what you are looking at

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam

    Post Edited (sam_sam_sam) : 6/19/2007 4:30:13 PM GMT
  • BeanBean Posts: 8,129
    edited 2007-06-19 16:36
    [b]Let's say you wanted to do something if (A = 1) OR (B = 2)[/b]
    

    SX/B does not allow multiple conditions for an IF...THEN statement.

    But the code I posted does the same thing.

    "LOOP NEVER" means to never loop, or the same thing as "LOOP UNTIL A·= A"

    Bean.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    “The United States is a nation of laws -· poorly written and randomly enforced.” - Frank Zappa

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    www.hittconsulting.com
    ·
  • JonnyMacJonnyMac Posts: 8,942
    edited 2007-06-19 16:43
    I think what Bean is trying to say that LOOP NEVER is a convenient way to create a custom label for when your complex expression is false. Without it you could do something like this:

    Evaluation:
      IF a <> 1 THEN
        IF b <> 2 THEN
          GOTO Evaluation_Failed
        ENDIF
      ENDIF
    
    Evaluation_Succeeded:
      ' handle it
      GOTO Next_Process
    
    Evaluation_Failed:
      ' handle it
    
    Next_Process:
      ' handle it
    



    One of the things that the SX/B reveals is that many of our *fancy* programming structures, things like IF-THEN-ELSE, are executed with simple test-and-jump code with the compiler automating the labels that I created manually in the example above.
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2007-06-19 20:02
    JonnyMac

    Evaluation:
    ··IF·a·<>·1·THEN
    ····IF·b·<>·2·THEN
    ······GOTO·Evaluation_Failed
    ····ENDIF
    ··ENDIF

    Evaluation_Succeeded:
    ··'·handle·it
    ··GOTO·Next_Process

    Evaluation_Failed:
    ··'·handle·it

    Next_Process:
    ··'·handle·it


    Thank You·For explaning it this way
    Now·I understand what you are talking about

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam
Sign In or Register to comment.