Stata 15 help for filewrite

[FN] Programming functions

Function

filewrite(f,s[,r]) Description: writes the string specified by s to the file specified by f and returns the number of bytes in the resulting file

If the optional argument r is specified as 1, the file specified by f will be replaced if it exists. If r is specified as 2, the file specified by f will be appended to if it exists. Any other values of r are treated as if r were not specified; that is, f will only be written to if it does not already exist.

When the file f is freshly created or is replaced, the value returned by filewrite() is the number of bytes written to the file, strlen(s). If r is specified as 2, and thus filewrite() is appending to an existing file, the value returned is the total number of bytes in the resulting file; that is, the value is the sum of the number of the bytes in the file as it existed before filewrite() was called and the number of bytes newly written to it, strlen(s).

If the file exists and r is not specified as 1 or 2, or an error occurs while writing to the file, then a negative number (#) is returned, where abs(#) is a standard Stata error return code. Domain f: filenames Domain s: strings Domain r: integers 1 or 2 Range: integers


© Copyright 1996–2018 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index