Jump to content

Make a backup file: Difference between revisions

m
→‎{{header|REXX}}: added/changed whitespace and comments.
(→‎{{header|Python}}: Added a version using pathlib)
m (→‎{{header|REXX}}: added/changed whitespace and comments.)
Line 522:
=={{header|REXX}}==
This REXX version executes under DOS or DOS under Windows.
<lang rexx>/*REXX pgmprogram 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 /*No argument? Then issue an err msg.*/
tFID=oFID'.$$$' say /'***error***create temporaryno namefileID forwas the backupspecified.*/'
call lineout oFID exit /*close the file (in case it's open). */13
call lineout tFID /* " " " " " " " */end
tFID= oFID'ERASE.$$$' tFID /*deletecreate thetemporary backupname filefor (ifthe it exists)backup.*/
'RENAME'call lineout oFID tFID /*renameclose the original file to backup.(in case it's open). */
call lineout oFID,'═══ThistFID is line 1.' /*write one line" " " " " " to" the original file. */
'ERASE' tFID /*stickdelete athe forkbackup infile (if it, we're all done. exists)*/</lang>
'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''':
<pre>
Cookies help us deliver our services. By using our services, you agree to our use of cookies.