Sujet : Re: Reverse SCAN SPLIT
De : dxforth (at) *nospam* gmail.com (dxf)
Groupes : comp.lang.forthDate : 07. Oct 2024, 13:07:16
Autres entêtes
Organisation : i2pn2 (i2pn.org)
Message-ID : <586c9cbef8f2205264590221dd832e1c2cecdf35@i2pn2.org>
References : 1 2 3
User-Agent : Mozilla Thunderbird
On 7/10/2024 9:03 pm, Ahmed wrote:
And with 00 for hours and minutes when they are absent
: :t ( add cnt -- add 2 1 | add1 2 add2 2 2 | add1 2 add2 2 add3 2 3)
0 -rot bounds dup >r swap do
i c@ [char] : = if 1+ i 1+ 2 rot then
1 -loop 1+ r> 2 rot ;
: .t ( n --)
case
1 of ." 00 hrs" space ." 00 min" space type space ." sec" endof
2 of ." 00 hrs" space type space ." min" space type space ." sec"
endof
3 of type space ." hrs" space type space ." min" space type space
" sec" endof
endcase ;
s" 10:20:30" :t .t 10 hrs 20 min 30 sec ok
s" 20:30" :t .t 00 hrs 20 min 30 sec ok
s" 30" :t .t 00 hrs 00 min 30 sec ok
Interesting. I'd do the numeric conversion in the main routine if possible.
There's a parsing issue with s" :30"