The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(71B) How to read the date in Forth ?
11-14-2023, 08:01 AM (This post was last modified: 11-16-2023 09:26 PM by floppy.)
Post: #1
(71B) How to read the date in Forth ?
Hello,
for having the correct clock in Forth, I make SETTIME"08:37:30" in the Basic prompt then read later the time with the TIME word and redefine HH MM SS based on it (see code below; TIMEUPDT).
Is there any DATE word in Forth anywhere? could not find it.

I made the Sylvain Cote VIDEO2 (=Clock in BASIC) in Forth. See below.
a) set time with above command in BASIC
b) start with 23 11 14 STARTCLO in the Forth prompt
c) exit anytime by clicking on the key E

However, still working on it because few rendering issues under Linux EMU71 Video80 (example, when the file is uploaded, the word DRAW-FRAMEC act a bit weird; the program work fine in a gforth cross-development, see screen copy in the attachment; I will have to test on Hardware to see if this is a Forth/EMU71/Display issue due to any 80char buffering or other).

Code:

( original from Sylvain Cote VIDEO2 in HP forum )
( updates under CC BY SA CreativeCommons floppy @ )
( https://www.hpmuseum.org/forum/ )
56 10 STRING-ARRAY NUMBCLO
" ##########    ####    ####    ####    ####    ##########"
1 NUMBCLO S!
"    ##      ##      ##      ##      ##      ##      ##   "
2 NUMBCLO S!
" ########      ##      ############      ##      ########"
3 NUMBCLO S!
" ########      ##      ## #######      ##      ##########"
4 NUMBCLO S!
" ##      ##      ##    ##########      ##      ##      ##"
5 NUMBCLO S!
" ##########      ##      ########      ##      ##########"
6 NUMBCLO S!
" ##########      ##      ##########    ####    ##########"
7 NUMBCLO S!
" ########      ##      ##      ##      ##      ##      ##"
8 NUMBCLO S!
" ##########    ####    ############    ####    ##########"
9 NUMBCLO S!
" ##########    ####    ##########      ##      ##########"
10 NUMBCLO S!
VARIABLE YY
VARIABLE MM
VARIABLE DD
: DATESET DD ! MM ! YY ! ;
VARIABLE TIMEHH
VARIABLE TIMEMM
VARIABLE TIMESS
VARIABLE TIMEHH-N
VARIABLE TIMEMM-N
VARIABLE TIMESS-N
: TIMEUPDT TIME FTOI DUP 3600 / TIMEHH ! 3600 MOD DUP 60 /
TIMEMM ! 60 MOD TIMESS ! ;
: TIMEUPDT-N TIME FTOI DUP 3600 / TIMEHH-N ! 3600 MOD DUP 60 /
TIMEMM-N ! 60 MOD TIMESS-N ! ;
72 STRING LCLO
" +----------------------------------------------------------------------+"
LCLO S!
: DRAW-FRAME 1 1 AT-XY LCLO TYPE 1 11 AT-XY LCLO TYPE 1 21 AT-XY
LCLO TYPE 11 2 DO 1 I AT-XY ." |" LOOP 11 2 DO 72 I AT-XY ." |"
LOOP 21 12 DO 1 I AT-XY ." |" LOOP 21 12 DO 72 I AT-XY ." |"
LOOP ;
: DRAW-SEP 24 6 AT-XY ." ##" 48 6 AT-XY ." ##" 25 15 AT-XY ." #"
49 15 AT-XY ." #" 25 17 AT-XY ." #" 49 17 AT-XY ." #" ;
: OUTNB 1 + NUMBCLO DROP 8 1 DO 9 1 DO DUP C@ SWAP 1 CHARS +
SWAP 4 PICK I + 1 - 4 PICK J + 1 - AT-XY EMIT LOOP LOOP DROP
DROP DROP ;
: DRAW-DATE 4 3 YY @ 10 / OUTNB 14 3 YY @ 10 MOD OUTNB 28 3 MM @
10 / OUTNB 38 3 MM @ 10 MOD OUTNB 52 3 DD @ 10 / OUTNB 62 3 DD @
10 MOD OUTNB ;
: UPDATE-SS 52 13 TIMESS-N @ 10 / OUTNB 62 13 TIMESS-N @ 10 MOD
OUTNB ;
: UPDATE-MM 28 13 TIMEMM-N @ 10 / OUTNB 38 13 TIMEMM-N @ 10 MOD
OUTNB ;
: UPDATE-HH 4 13 TIMEHH-N @ 10 / OUTNB 14 13 TIMEHH-N @ 10 MOD
OUTNB ;
: INITCLO DELAY00 PAGE DRAW-FRAME DRAW-SEP DATESET DRAW-DATE
TIMEUPDT TIMEUPDT-N UPDATE-SS UPDATE-MM UPDATE-HH ;
: UPDATE-CLOCK TIMEUPDT-N TIMEHH @ TIMEHH-N @ <> IF UPDATE-HH
UPDATE-MM UPDATE-SS TIMEHH-N @ TIMEHH ! TIMEMM-N @ TIMEMM !
TIMESS-N @ TIMESS ! ELSE TIMEMM @ TIMEMM-N @ <> IF UPDATE-MM
UPDATE-SS TIMEMM-N @ TIMEMM ! TIMESS-N @ TIMESS ! ELSE TIMESS @
TIMESS-N @ <> IF UPDATE-SS TIMESS-N @ TIMESS ! ELSE THEN THEN
THEN ;
: RETIMELO BEGIN UPDATE-CLOCK ?TERMINAL IF KEY DUP 69 <> IF 101
<> IF FALSE ELSE TRUE THEN ELSE DROP TRUE THEN ELSE FALSE THEN
UNTIL ;
: STARTCLO INITCLO RETIMELO TIMEUPDT ;


UPDATE: going around the topic with BASIC commands bring a solution. See below. However, any comment is welcome.

In the Forth mode
“ SETDATE’23/11/14’” BASICX ( .. set the date )
“ DATE$” BASIC$ ( return a string in stack 213239 8 which can be viewed with TYPE 23/11/14 )


Attached File(s) Thumbnail(s)
   

HP71B 4TH/ASM/Multimod, HP41CV/X/Y & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(71B) How to read the date in Forth ? - floppy - 11-14-2023 08:01 AM



User(s) browsing this thread: 1 Guest(s)