quick Forth question

Edward Cherlin echerlin at gmail.com
Mon Jan 25 11:27:51 EST 2010


On Mon, Jan 25, 2010 at 10:59, Daniel Drake <dsd at laptop.org> wrote:
> Can anyone help me with a tiny Forth script? Can never quite get my
> head around the language.

I once wrote pen plotter programs in FORTH for fractals, to test the
plotter mechanism. Hypnotic.

> I'm trying to set up an if-else based on whether a mfg tag exists (or
> whether writing a mfg tag succeeded or not)
>
> I'm trying:
>
>    add-tag ak 0 catch if 2drop ." Laptop already activated" cr then
>
> But, if ak already exists, it simply says:
>    Tagname already exists
> ...rather than executing my conditional code.

That isn't very FORTHish, to have the argument to add-tag come after.
Is that right?

Your description is incomplete, and looks incorrect. My guess is that
add-tag gives you the  Tagname already exists  message, and then FORTH
continues, executing your conditional when it gets to it, and dropping
two items from the stack. Please check.

Here is what we need in order to comment usefully:

Stack picture before starting.
Expected result of add-tag, with stack picture.
Expected result of ak, with stack picture. Is ak the address of a string?
We're OK about putting 0 on the stack.
Expected result of catch, with stack picture.

Once you have all of that, you may not need our help. You can compare
it with what actually happens by inserting stack display words.

> Also experimented with find-tag but couldn't figure it out.
>
> cheers,
> Daniel
> _______________________________________________
> Devel mailing list
> Devel at lists.laptop.org
> http://lists.laptop.org/listinfo/devel
>



-- 
Edward Mokurai (默雷/धर्ममेघशब्दगर्ज/دھرممیگھشبدگر ج) Cherlin
Silent Thunder is my name, and Children are my nation.
The Cosmos is my dwelling place, the Truth my destination.
http://www.earthtreasury.org/



More information about the Devel mailing list