RosettaCodeData/Task/File-input-output/Forth/file-input-output-1.fth

15 lines
341 B
Forth
Raw Permalink Normal View History

2023-07-01 11:58:00 -04:00
\ <to> <from> copy-file
: copy-file ( a1 n1 a2 n2 -- )
r/o open-file throw >r
w/o create-file throw r>
begin
2023-07-22 21:42:12 -07:00
pad 84 2 pick read-file throw
?dup while
2023-07-01 11:58:00 -04:00
pad swap 3 pick write-file throw
repeat
close-file throw
close-file throw ;
\ Invoke it like this:
s" output.txt" s" input.txt" copy-file