Path: utzoo!mnetor!tmsoft!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!olivea!decwrl!deccrl!news.crl.dec.com!decvax.dec.com!shlump.nac.dec.com!jareth.enet.dec.com!edp From: edp@jareth.enet.dec.com (Eric Postpischil (Always mount a scratch monkey.)) Newsgroups: comp.sys.handhelds Subject: Re: Using CLEAR in progs (Was: Re: new puzzle, new blinky) Keywords: 48sx, CLEAR, programs Message-ID: <19504@shlump.nac.dec.com> Date: 28 Jan 91 13:57:55 GMT References: <1991Jan26.221145.29164@portia.Stanford.EDU> <25590090@hpcvra.cv.hp.com.> <56027@eerie.acsu.Buffalo.EDU> <19462@shlump.nac.dec.com> Sender: newsdaemon@shlump.nac.dec.com Reply-To: edp@jareth.enet.dec.com (Eric Postpischil (Always mount a scratch monkey.)) Organization: Digital Equipment Corporation Lines: 19 It has been pointed out that saving the stack is simple (DEPTH ->LIST -> local). However, this method runs the risk of losing the entire stack should the program terminate abnormally -- whether by internal error or the user pressing on/attention. Still, there are times when it is useful to restore the stack to a fixed point. For example, after running a clause in an IFERR statement, which can leave a variable number of objects on the stack, depending upon where an error is encountered or the setting of the last-arguments flag. One person suggested a clear-to-mark routine which scanned the stack looking for a particular argument. However, this routine is slow and does not distinguish between marks left by different invocations. A simpler way to accomplish this is: DEPTH -> STACKLEVEL << program >>. Anywhere in the program, the stack can be restored to the initial point with DEPTH STACKLEVEL - DROPN. -- edp (Eric Postpischil) "Always mount a scratch monkey." edp@jareth.enet.dec.com