dos_compilers/DX-FORTH v430/TXT2BLK.SCR

1 line
9.0 KiB
Plaintext
Raw Permalink Normal View History

2024-07-09 18:07:02 +02:00
\ TXT2BLK - Information Convert ascii text files to forth screens. A minor quirk with this utility is that if a text line is exactly 64 characters then an extra blank line will appear in the screen file. This can be avoided by using the -T option; however lines greater than 64 characters will be truncated. The -1 switch permits writing one line per screen. \ TXT2BLK - Load screen FORTH DEFINITIONS DECIMAL APPLICATION 2 #SCREENS 1- THRU \ compile program TURNKEY MAIN TXT2BLK \ create turnkey application \ TXT2BLK - HELP ARGV GETARG \ Show help : HELP ( -- ) ." Usage: TXT2BLK [-opt] file[.TXT] file[.SCR]" CR ." Convert ASCII text files to Forth screens." CR ." -T truncate lines" CR ." -1 one line per screen" CR ; \ Parse blank delimited argument from commandline. : ARGV ( n -- adr u -1 | 0 ) 0 0 ROT 128 COUNT ROT 0 ?DO 2NIP BL SKIP 2DUP BL SCAN ROT OVER - -ROT LOOP 2DROP DUP IF -1 ELSE AND THEN ; \ Get argument, if none show help and exit : GETARG ( n -- adr u ) ARGV 0= IF HELP ABORT THEN ; \ TXT2BLK - F1 F2 H1 H2 CNT TFLAG 1LINE C/L FERROR \ Filename buffers CREATE F1 80 ALLOT CREATE F2 80 ALLOT \ File handles VARIABLE H1 VARIABLE H2 VARIABLE CNT VARIABLE TFLAG VARIABLE 1LINE 64 VALUE C/L 1024 VALUE B/BUF \ Display filename and exit : FERROR ( adr -- ) COUNT TYPE ABORT ;