Sujet : Re: May the numbers speak - supplement
De : minforth (at) *nospam* gmx.net (minforth)
Groupes : comp.lang.forthDate : 12. Jun 2025, 16:01:58
Autres entêtes
Organisation : novaBBS
Message-ID : <1d5b0d1dccd0854f8ebbed983523203f@www.novabbs.com>
References : 1 2 3 4 5 6 7 8
User-Agent : Rocksolid Light
On Thu, 12 Jun 2025 9:59:56 +0000, Paul Rubin wrote:
This version with the string in memory, no error checking, and using a
variable, seems simplest to me.
>
variable p
: advance ( -- ) 1 p +! ;
: digit ( -- n ) p @ c@ '0' - advance ;
: 2digit ( -- n ) digit 10 * digit + ;
: hms ( a u -- h m s ) drop p !
2digit advance 2digit advance 2digit advance ;
: test clearstack s" 12:34:56" hms ;
>
test .s
Yes, good point. In my toolbox are two words
STR-PARSE ( a u c -- ap up )
STR-PARSE-NAME ( a u -- ap up )
as twins to the standard words. They also use SKIP / SCAN
but work on strings in memory, without needing to switch
SOURCE. Now and then they are quite handy.
--