ProvideX V8.20 > Language Reference > 2. Directives
276
REFILE Directive
          Clear Data from File
Format
REFILE filename$[,ERR=stmtref]
Where:
filename$ Name of the file to clear. String expression.
stmtref
Program line number or label to transfer control to.
Description
Use the REFILE directive to erase all data in a specified file. If you use the REFILE
directive to erase a file, the file still exists in the system but contains no data.
(ProvideX returns disk space to the system while preserving the lock.) Any READ
directives for the file will return an End-of-File message.
Using either the REFILE or PURGE directive is faster than deleting the file and
recreating it.
If the given filename does not already exist, ProvideX returns an Error #12:
File does not exist (or already exists). If the file is in use by another
user, ProvideX returns an Error #0: Record/ file busy. Unlike the PURGE
directive, the REFILE directive works if the file is not opened.
WindX supports the use of this directive via the [WDX] tag; e.g., REFILE
"[WDX]somefile.ext"... For more information, see [WDX] Direct Action to
Client Machine, p.797.
See Also
LOCK Reserve File for Exclusive Use, p.199,
PURGE Clear Data from a File, p.261.
Creating, Deleting, and Renaming Data Files, User's Guide
Example
0010
REFILE "PRNTFL"! Pre-clear datafile
0020
OPEN (2)"PRNTFL"
0030
LOCK (2)
0040
PRINT (2)'FF',"Date:",DAY,@(40),TTL$
0050
...