\\ Fileoutput 09nov97py Ausgaberoutinen in eine File Entweder im ASCII-Format (Zeile mit CR LF abgeschlossen) oder im FORTH-Screen-Format: Die ASCII-Routinen sind für ein Bildschirmprotokoll gedacht, das mit +FILE automatisch angeschaltet wird. Die SCR-Routinen sind nicht für ein Echo gedacht, da sie nur eine maximale Zeilenlänge von 64 Zeichen haben und das meistens zu wenig ist. Mit ' >SCR +OUT kriegt man natürlich auch ein Echo. Auf dem letzten Block stehen noch Umwandlungsroutinen zur Verfü-gung, mit denen man ASCII- in FORTH-Format und umgekehrt wandelnkann. \ Fileoutput 12sep08py Module FileOP Dos also FileOP 1 2 +thru \ FILE-Format 3 4 +thru \ SCR-Format 5 +load \ FILE>SCR SCR>FILE toss export fileop output-file >file +file >scr scr>file file>scr ; Module; \ Alle FILEoutput Routinen 25may97py User fhandle fhandle off | User oldout | Create fchar 0 c, | Create crlf 1 c, #lf c, : FILEtype fhandle @ filehandle @ fwrite ?diskabort ; : FILEemit ( char -- ) fchar under c! 1 FILEtype ; : FILEcr ( -- ) crlf count FILEtype ; : FILEpage FILEcr $0C FILEemit FILEcr ; : FILEeot ( -- ) oldout @ output ! fhandle @ fhandle off close-file throw ; Output: FILEout FILEemit true FILEcr FILEtype noop FILEpage 2drop 0. PCform noop FILEeot noop noop noop noop noop [ \ 0name >FILE +FILE 12mar00py : output-file ( addr u mode -- ) fhandle @ ?dup IF close-file drop fhandle off THEN create-file throw fhandle ! output @ oldout ! FILEout ; : >FILE ( -- ) \ bl word count r/w output-file +buffer ; : +FILE ['] >FILE +Out ; \ Variablen, Ausgabe 07jul89py| Variable >r# >r# off | Variable >scr# >scr# off Variable wrap wrap off | : >where ( -- pos restlen ) >scr# @ block >r# @ + b/blk >r# @ - ; : SCRpage ( -- ) 1 >scr# +! >scr# @ capacity < 0= IF 1 (more THEN >r# off ; : SCRtype ( string len -- ) dup >r# @ + b/blk Q/mod swap >r 0 ?DO over >where dup >r move update SCRpage r> - LOOP >where drop swap move update r> >r# ! ; : SCRemit ( char -- ) >where 0= IF drop SCRpage >where drop THEN c! update 1 >r# +! wrap @ IF >r# @ c/l Qmod 0= IF -1 >r# +! THEN THEN ; : SCRcr ( -- ) >r# @ c/l under Qmod - >r# @ + b/blk Q/mod IF SCRpage THEN >r# ! ; \ Ausgabe 02dec93py| Variable ?SCR ?SCR off : SCRat ( row col -- ) swap c/l * + b/blk Qmod >r# ! ; : SCRat? ( -- row col ) >r# @ c/l Q/mod swap ; : SCRdel ( -- ) -1 >r# +! space -1 >r# +! ; : SCRform ( -- rows cols ) l/s c/l ; : SCRcurleft ( -- ) -1 >r# @ + 0 max >r# ! ; : SCRcurrite ( -- ) -1 >r# @ + b/blk 1- min >r# ! ; : SCRclrline ( -- ) >scr# @ block >r# @ c/l negate and c/l bl fill update ; : SCReot close oldout @ output ! ?SCR off >scr# off ; Output: SCRout SCRemit true SCRcr SCRtype SCRdel SCRpage SCRat SCRat? SCRform noop SCReot noop noop SCRcurleft SCRcurrite SCRclrline [ : >SCR ?SCR @ 0= IF >in @ makefile >in ! use SCRpage >scr# off ?SCR on THEN output @ oldout ! SCRout ; \ SCR>FILE FILE>SCR 04mar92py: SCR>FILE ( -- ) \ File.scr File.txt isfile push fromfile push Use >FILE Capacity 0 DO $10 0 DO j block i c/l * + c/l -trailing type cr LOOP LOOP eot Close ; | : VT52emit ( char -- ) #cr case? IF cr exit THEN #lf case? IF col IF cr THEN exit THEN &9 case? IF 8 col 8 mod - spaces exit THEN $0C case? IF page exit THEN bl max emit ; : FILE>SCR ( -- ) \ File.Txt File.scr isfile push fromfile push wrap dup push on use isfile@ ?SCR off >SCR fromfile ! fromfile @ filesize @ 0 DO i b/blk Q/mod fromfile @ (block + c@ VT52emit LOOP isfile@ fromfile @ !files close! !files eot ;