![]() |
||
| Home | SwiftForth Archive | SwiftX Archive | |

----- Original Message -----
From: "Richard Owlett" <rcowlett_at_atlascomm.net>
To: <sftalk_at_forth.com>
Sent: Thursday, August 10, 2006 1:22 PM
Subject: [sftalk] Which defining word do I want?
>I haven't tried to write any FORTH in a couple of years and was never
> proficient in the first place. I think my problem is confusing bits
> and
> pieces of defining words, especially BUILDS and DOES>. I've looked at
> relevant sections of the "User Manual" and "Forth Programmers
> Handbook".
> Unfortunately I can't find my copy of "Forth Application Techniques".
>
[snip]
> date$ time$ 3*calories 3*fat 3*protein 3*carbs 3*sodium
>
> I'd would also keep a running total that could be appended to the same
> file, replacing time with "****". This operation would reset the the
> running totals to zero.
>
Two words to store time (without second) and date in a single cell.
\ TIME&DATE (without conversion) routines.
\ TIME&DATE drop ( min hour day month year )
\ max 59 24 31 12 maximum
\ bit needed 6 5 5 4 32 - (6+5+5+4) = 12 = $FFF years
: T&D>N ( min hour day month year -- n )
4 lshift or
5 lshift or
5 lshift or
6 lshift or ;
: N>T&D ( n -- min hour day month year )
dup $3F and swap 6 rshift
dup $1F and swap 5 rshift
dup $1F and swap 5 rshift
dup $0F and swap 4 rshift ;
\\ test
: ?<> ( a b -- )
<> abort" convertion error" ;
: TEST
0 0 0 0 0 locals| min hour day month year |
60 0 DO i dup to min . cr
24 0 DO i to hour
32 1 DO i to day
13 1 DO i to month
2100 2000 DO i to year
min hour day month year t&d>n
n>t&d
year ?<>
month ?<>
day ?<>
hour ?<>
min ?<>
LOOP
LOOP
LOOP
LOOP
LOOP ;
----------------------------------------------------------------------
sftalk_at_forth.com The SwiftForth programming discussion email list
To unsubscribe, send subject "unsubscribe" to sftalk-request_at_forth.com
For list command help, send subject "help" to sftalk-request_at_forth.com
Message archives are located at http://www.forth.com/archive/sftalk
----------------------------------------------------------------------
This list is a forum for SwiftForth users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Thu Aug 10 2006 - 11:37:31 PDT
This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:40 PST