Shop OBEX P1 Docs P2 Docs Learn Events
Question about Stop, Sleep, and End. Yes, I checked the help guides. — Parallax Forums

Question about Stop, Sleep, and End. Yes, I checked the help guides.

flylikechrisflylikechris Posts: 3
edited 2012-07-22 04:36 in BASIC Stamp
Hi guys, my teacher asked me two questions that have been giving me problems.

1) Which command can not be used inside of a DO...LOOP structure?"
s) FOR...NEXT b) STOP c) SLEEP d) END e) None of the Above

2) The STOP command can be used inside of a DO...LOOP structure. True of False?

The problem is that technically I can put any of these commands in the DO..LOOP.
Even if not logical..

Especially considering END and STOP perform almost the exact same function (with the exception of power save mode).


Any ideas?
thanks!

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2012-07-18 14:06
    A DO...LOOP structure is just like (and is translated internally into):

    someLabel:
    '... inside the DO...LOOP
    GOTO someLabel

    You can have any statement inside the DO...LOOP as long as things like other DO...LOOP, IF...ENDIF, and FOR...NEXT statements fit completely inside. For example, you can't have DO...FOR...LOOP...NEXT. Whether what you've written makes sense and whether what you write executes the way you want is something else entirely. We can't give you the answers to your homework, but think about what you know, think about the various statements, and reread the descriptions in the Basic Stamp Manual.
  • LoopyBytelooseLoopyByteloose Posts: 12,537
    edited 2012-07-20 10:20
    Technically, I say 'none of the above', but STOP and END really terminate the purpose of the loop.

    The micro-controllers for the BS have an assembly instruction called SKIP, an unconditional skip of the next line of code. But why would one write a line of code and then skip it? There may be a reason, but I find it hard to see one.

    In other words, there are technical possibilities in writing programs that are somewhat absurd. Just like oxymorons in language. Have you ever met an 'honest liar'?

    BTW, the real answer is to test each and see which actually work.
  • IroneIrone Posts: 116
    edited 2012-07-22 04:36
    Have you ever met an 'honest liar'?

    Now hold the phone there for a couple of minutes, in my 65 years I have not stole or killed anyone. I have been fateful to my wife and have not cheated anyone. My word is my oath and if I say I will do something I really mean it. (Except for maybe one more beer to my wife) I actually slow down on the back roads for ducks and cats while I am driving. The only problem is I like to go fishing which makes most people think I lie. Whoa there, they are right!
Sign In or Register to comment.