Jump to content

Make a backup file: Difference between revisions

→‎{{header|REXX}}: added the REXX language.
m (Page and category names are case-sensitive)
(→‎{{header|REXX}}: added the REXX language.)
Line 313:
(revise "fff")
</lang>
 
=={{header|REXX}}==
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.*/
parse arg oFID .
if oFID=='' then do; say '***error*** no fileID was specified.'; exit 13; end
tFID=oFID'.$$$' /*create temporary name for the backup.*/
call lineout oFID /*close the file (in case it's open). */
call lineout tFID /* " " " " " " " */
'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''':
<pre>
AA FFFFFFFFFFFF IIIIII LLLL EEEEEEEEEEEE
AAAA FFFFFFFFFFFF IIIIII LLLL EEEEEEEEEEEE
AA AA FF FF II LL EE EE
AA AA FF II LL EE
AA AA FF FF II LL EE EE
AA AA FFFFFFF II LL EEEEEEE
AAAAAAAAAA FFFFFFF II LL EEEEEEE
AAAAAAAAAA FF FF II LL LLLL EE EE
AA AA FF II LL LLLL EE
AA AA FF II LL LL EE EE
AAAA AAAA .. FF IIIIII LLLLLLLLLL EEEEEEEEEEEE
AAAA AAAA .. FF IIIIII LLLLLLLLLL EEEEEEEEEEEE
</pre>
The contents of the overwritten file (after execution): &nbsp; '''A.FILE''':
<pre>
═══This is line 1.
</pre>
The backup file is called: &nbsp; '''A.FILE.$$$'''
<br><br>
 
=={{header|Ruby}}==
Cookies help us deliver our services. By using our services, you agree to our use of cookies.