2022-03-01 13:02:46 +00:00
|
|
|
\ logging to a text file phz 03jan22 \ load screen phz 25feb22 Code m+! ( 16b addr -- ) D W mov W inc W inc A pop A W ) add CS ?[ W dec W dec W ) inc ]? D pop Next end-code : (blk blk @ 0= IF ascii ) parse 2drop THEN ; (blk 1 2 +thru ( ) \ log-type log-emit log-cr phz 25feb22 context @ dos also context ! \ vocabulary log dos also log definitions file logfile variable logfcb variable logpos 0 , : log-type ( addr count -- ) dup logpos m+! 2dup (type ds@ -rot logfcb @ lfputs ; : log-emit ( char -- ) 1 logpos m+! dup (emit logfcb @ fputc ; : log-cr ( -- ) 2 logpos m+! (cr #cr logfcb @ fputc #lf logfcb @ fputc ; \ alsologtofile logopen logclose logreopen phz 25feb22 Output: alsologtofile log-emit log-cr log-type (del (page (at (at? ; : logopen ( -- ) isfile push logpos dup 2+ off off logfile make isfile@ dup freset logfcb ! alsologtofile ; : logclose ( -- ) display logfcb @ fclose ; : logreopen ( -- ) logfcb @ freset logpos 2@ logfcb @ fseek alsologtofile ;
|