quick Forth question

Richard A. Smith richard at laptop.org
Mon Jan 25 12:44:49 EST 2010


On 01/25/2010 12:05 PM, Paul Fox wrote:

>
> maybe something like:
>     " ak" find-tag  if  2drop ." Laptop already activated" cr then
>
> i'm pretty much a neophyte too, but i believe the commands that one
> types at the ok prompt that "feel" like command, with trailing args,
> should be avoided when scripting.  i'm sure they can be used, but no
> doubt some special sauce is needed.

I worked it out.

: check-ak " add-tag ak 0" eval ;

ok ' check-ak catch if ." Laptop already activated" cr then

If you want to use it in a word then you need ['] rather than '

: do-me ['] check-ak catch if ." Laptop already activated" cr then

ok do-me

You can think of ' as the C & operator.  ' gets the reference to the 
word and that's what you have to give to catch so it can grab the exception.

-- 
Richard A. Smith  <richard at laptop.org>
One Laptop per Child



More information about the Devel mailing list