MAINSAIL Language Manual, Section 32.73

previous   next   top   contents   index   framed top   this page unframed


32.73. $createUniqueFile

Figure 32–75. $createUniqueFile (GENERIC)
BOOLEAN
PROCEDURE   $createUniqueFile
                        (
PRODUCES POINTER(textFilef;
                         
BITS openBits;
                         
PRODUCES OPTIONAL STRING msg;
                         
OPTIONAL STRING
                             
devModStr,path,extension);

BOOLEAN
PROCEDURE   $createUniqueFile
                        (
PRODUCES POINTER(dataFilef;
                         
BITS openBits;
                         
PRODUCES OPTIONAL STRING msg;
                         
OPTIONAL STRING
                             
devModStr,path,extension);

$createUniqueFile creates a uniquely named file. This is useful for temporary files, especially if such files might be created by more than one instance of the same program on the same file directory. If successful, it returns TRUE, with f equal to the newly opened file (opened with openBits, as described for the system PROCEDURE open, except that create is always set and prompt is ignored); otherwise, it returns FALSE, sets msg to a STRING describing why the file could not be opened, and sets f to Zero.

The format of the error message STRING msg is as described for the system PROCEDURE open.

Between the time a unique file name is found and the time that the file is created, it is possible for some other process to create a file with the same name. The probability of this happening is small but increases with the number of processes creating files on the same directory.

By default, unique file names are presently of the form znumber.tmp, where number is an INTEGER of up to five digits. This format is subject to change.

$createUniqueFile allows the caller to specify the device MODULE, path, and extension of the file created. The meaning of these parameters is device-specific, but is the same as specified to $composeFileName for the device. Each of these parameters that is non-zero overrides $createUniqueFile's default value for that parameter. For example, to cause a temporary file to have the extension xyz (instead of the default tmp):

$createUniqueFile(f,output,msg,"","","xyz")

previous   next   top   contents   index   framed top   this page unframed

MAINSAIL Language Manual, Section 32.73