To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcx.pbforthOpen lugnet.robotics.rcx.pbforth in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / pbFORTH / 546
545  |  547
Subject: 
Breaking from infinite loops
Newsgroups: 
lugnet.robotics.rcx.pbforth
Date: 
Tue, 16 Jul 2002 08:43:17 GMT
Viewed: 
2296 times
  
This feels vaguely similar to a question just recently posed, almost.

I need a way to get out of a user program that intentionally defines an
infinite loop. My best attempt so far at an exit word

: exit POWER_OFF LCD_4TH LCD_REFRESH ;

in the context of code like the following:

(define (loop)
  (begin
    (if (run-button-held?)
        (exit)
        (begin
          (sound-tone 100 440)
          (sleep 10)))
    (loop)))

(loop)

my 'exit' is not very exciting; when the Run button is held down, the RCX
does indeed power down. When I power it back up, it continues beeping...
picking up right where it left off (as it should, according to the semantics
of POWER_OFF).

I really need to be able to introduce the (exit) concept into my high-level
programs. That (exit) should power down the RCX, and when I come back (turn
the RCX on), the Forth interpreter should be idling, waiting for input (that
is, I can resume console interaction). Furthermore, it should do this
without destroying the current ... namespace? dictionary?; I'd like to be
able to restart the program that was running from the console, if so
desired, or inspect values stored on the brick, etc.

Thanks,

Matt

(PS - Thanks Mario for the tip on the last message; it solved my problem; I
was missing the obvious. And a belated thanks to Ralph for hints re: the
MARKER word. I've been happily cleaning up after myself download after
download with it.)

(PPS - I see some similarities between this question and the ISR question,
and my initial experiments with ['] NoOp and such things have produced no
results. This is expected, however, because I don't know what I'm doing there.)



Message has 1 Reply:
  Re: Breaking from infinite loops
 
(...) Hi, if you just want to stop your "own" program use the Forth word ABORT or ABORT" : TEST 1000 0 DO \ do something run-button-down? ABORT" Aborted by user!" LOOP ; or if you want what looks like a "reset" use COLD: run-button-down? IF (...) (22 years ago, 16-Jul-02, to lugnet.robotics.rcx.pbforth)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR