dos_compilers/DX-FORTH v430/FCOPY.SCR

1 line
7.0 KiB
Plaintext
Raw Normal View History

2024-07-09 18:07:02 +02:00
\ FCOPY - Information A filecopy utility to demonstrate the use of the disk functions. \ Load screen FORTH DEFINITIONS DECIMAL APPLICATION 2 LOAD \ compile program TURNKEY MAIN FCOPY \ create turnkey application \ H1 H2 HELP ARGV \ File handles VARIABLE H1 VARIABLE H2 \ Show help : HELP ( -- ) ." Usage: FCOPY infile outfile" CR ." Filecopy utility" 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 ; --> \ GETARG FERROR BUFSIZE GET \ Get argument, if none show help and exit : GETARG ( n -- adr u ) ARGV 0= IF HELP ABORT THEN ; \ Display filename and exit : FERROR ( n -- ) ARGV IF TYPE THEN ABORT ; \ Buffer size - use max available memory, allow for stack etc : BUFSIZE ( -- u ) UNUSED 500 - ; \ Read u1 chars from input file, u2 = #chars actually read : GET ( u1 -- u2 ) PAD SWAP H1 @ READ-FILE ABORT" read error" ; -->