File input/output: Difference between revisions

Added Quackery.
(Add Emacs Lisp solution)
(Added Quackery.)
Line 3,039:
 
The files will automatically be closed on exit of their ''with:'' blocks. (Thus even if an I/O error occurred while reading the middle of the input file we are assured that the ''.close()'' method will have been called on each of the two files.
 
=={{header|Quackery}}==
 
Assuming that <code>input.txt</code> exists beforehand, and <code>output.txt</code> does not (so we can safely <code>drop</code> the success flag that file handling words return), and that we want both files to exist afterwards.
 
Quackery does not have variables, so instead we will move the file text to and from the ancillary stack <code>temp</code>, leaving a copy on the top of <code>temp</code>.
 
<lang Quackery> $ "input.txt" sharefile drop
temp put
temp share
$ "output.txt" putfile drop
</lang>
 
=={{header|R}}==
1,462

edits