Make a backup file: Difference between revisions

Content deleted Content added
Georgy (talk | contribs)
→‎{{header|Python}}: Added a version using pathlib
m →‎{{header|REXX}}: added/changed whitespace and comments.
Line 522: Line 522:
=={{header|REXX}}==
=={{header|REXX}}==
This REXX version executes under DOS or DOS under Windows.
This REXX version executes under DOS or DOS under Windows.
<lang rexx>/*REXX pgm creates a backup file (for a given file), then overwrites old file.*/
<lang rexx>/*REXX program creates a backup file (for a given file), then overwrites the old file.*/
parse arg oFID . /*get a required argument from the C.L.*/
parse arg oFID .
if oFID=='' then do; say '***error*** no fileID was specified.'; exit 13; end
if oFID=='' then do /*No argument? Then issue an err msg.*/
tFID=oFID'.$$$' /*create temporary name for the backup.*/
say '***error*** no fileID was specified.'
call lineout oFID /*close the file (in case it's open). */
exit 13
call lineout tFID /* " " " " " " " */
end
'ERASE' tFID /*delete the backup file (if it exists)*/
tFID= oFID'.$$$' /*create temporary name for the backup.*/
'RENAME' oFID tFID /*rename the original file to backup. */
call lineout oFID /*close the file (in case it's open). */
call lineout oFID,'═══This is line 1.' /*write one line to the original file. */
call lineout tFID /* " " " " " " " */
/*stick a fork in it, we're all done. */</lang>
'ERASE' tFID /*delete the backup file (if it exists)*/
'RENAME' oFID tFID /*rename the original file to backup. */
call lineout oFID, '═══This is line 1.' /*write one line to the original file. */
/*stick a fork in it, we're all done. */</lang>
The contents of the original file (before execution): &nbsp; '''A.FILE''':
The contents of the original file (before execution): &nbsp; '''A.FILE''':
<pre>
<pre>