Listing a File
Accessing Files
4–18
107365 Tandem Computers Incorporated
Figure 4-7. Listing a File (Page 3 of 5)
== Get dates macro
[#DEF get_dates TEXT |BODY|
#SET bin_date [#FILEINFO/MODIFICATION/ [file:input(0:33)]]
#SETMANY year month day file_hour file_min, &
[#CONTIME [bin_date]]
#SET file_date &
[#COMPUTE ((year - 1900) * 100000) + (month * 100) + day]
#SETMANY year month day list_hour list_min, &
[#CONTIME [#TIMESTAMP]]
#SET list_date &
[#COMPUTE ((year - 1900) * 100000) + (month * 100) + day]
]
== Main Part of the Code
=============================================================
== Look for the input file name. If empty, drop out of the
== loop and display an error.
[#IF NOT [#EMPTY %1%] |THEN|
#SET file:input(0:33) [#SHIFTSTRING/UP/%1%]
== Look for the out file name. If empty, use the default
== OUT file.
[#IF NOT [#EMPTY %2%] |THEN|
#SET file:output(0:33) [#SHIFTSTRING/UP/%2%]
|ELSE|
#SET file:output(0:33) [default_outfile]
]
== Open the input file for read access.
#SET err_inp [#REQUESTER/WAIT/READ [file:input(0:33)] &
err_inp rec_inp prompt]
[#IF err_inp <> 0 |THEN| == open error; drop out of loop.
#OUTPUT [file:input(0:33)] not open; error: &
[err_inp]
|ELSE|
== If the output file already exists, purge it.
[#IF [#FILEINFO/EXISTENCE/ [file:output(0:33)]] |THEN|
SINK [#PURGE [file:output(0:33)] ]
]
== Save (push) the current #OUT setting, then set it to
== the new value.
#PUSH #OUT
#SET #OUT [file:output(0:33)]