[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: problem with creating word
From: |
Robert Sander |
Subject: |
Re: problem with creating word |
Date: |
Fri, 10 Apr 2020 09:59:02 +0200 |
User-agent: |
Mutt/1.10.1 (2018-07-13) |
On Fri, Apr 10, 2020 at 09:12:06AM +0200, Anton Ertl wrote:
> On Fri, Apr 10, 2020 at 08:40:24AM +0200, Robert Sander wrote:
> > Hello,
> >
> > I want to create a word and store a generated id and a string in the
> > datafield.
> >
> > I have the following words:
> >
> > variable ma#
> > 68 ma# ! \ just to find the value in the memoy
> >
> > : ma: ( -- )
> > 1 ma# +! \ increment ma# - is there a better way?
> > create ma# @ , \ reserve space and store the value of ma#
> > parse-name 2, \ get next word and store addr and length
> > does> ( -- u) @ ;
> >
> >
> > With the following definition:
> >
> > ma: robert rs
> ...
> > Now I want to see the string "rs":
> >
> > ' robert >body 1 cells + 2@ type c ok
> >
> > but this does not work.
> >
> > What am I doing wrong?
>
> PARSE-NAME just points into the input buffer. The result is only
> valid until the text interpreter switches to the next line. You can
> make the name permanent (until the end of the session) with SAVE-MEM (
> c-addr1 u -- c-addr2 u ), i.e.:
>
> : ma: ( -- )
> 1 ma# +! \ increment ma# - is there a better way?
> create ma# @ , \ reserve space and store the value of ma#
> parse-name save-mem 2, \ get next word and store addr and length
> does> ( -- u) @ ;
>
> - anton
It works. Thanks a lot! I spent several hours searching in the wrong
place...