Post Reply 
RPL equivalents to BREAK, CYCLE, EXIT, etc.?
06-07-2014, 06:47 AM
Post: #6
RE: RPL equivalents to BREAK, CYCLE, EXIT, etc.?
(05-22-2014 09:27 AM)HP67 Wrote:  Are there User RPL equivalents to break out of loops or start the next iteration such as can sometimes be found in programming languages?
Error traps are a way for loops where you can't access the index easily, but you can exit FOR loops without generating an error condition.
Just set the index to the end value, and you're done;-)

Consider the following loop, which will run 100 times:
Code:
<< 1 100
   FOR x
     x DISP
   NEXT
>>

To break out of such a loop, you simply have to set the exit condition to TRUE.
The following code will exit the loop after 50 times:
Code:
<< 1 100
   FOR x
     x DISP
     IF x 50 ==
     THEN 100 'x' STO
     END
   NEXT
>>

The principle is the same for DO..UNTIL and WHILE..REPEAT loops, of course.

-- Ray
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: RPL equivalents to BREAK, CYCLE, EXIT, etc.? - Raymond Del Tondo - 06-07-2014 06:47 AM



User(s) browsing this thread: 1 Guest(s)