file_create()

 
Creates and appends data to the file in path.
Syntax
file_create( path, location, outputdata var )
Returns length of outputdata or -1 on error. file_create() will not append to an existing file, but return -1 if the file exists.
  • path = fully qualified path to the file
  • location = location of the output file - 'data' or 'script'
  • outputdata = string variable containing the data to append
User Annotations: file_create
Ray Yates : ray d0t yates at, pcinet d0t com
06/05/2011 06:54 a.m.
This function creates an error log file, writing a new line each time it's called.

It checks to see if the file exsists before using file_append(). If not it creates it using file_create()
<MvFUNCTION NAME = "error_log" PARAMETERS = "message" STANDARDOUTPUTLEVEL = "">
    <MvASSIGN NAME = "l.ok" VALUE = "{ Module_Description(l.module) }">
    <MvASSIGN NAME = "l.file" VALUE = "{ l.module:code $ '_error.log' }">

    <MvIF EXPR = "{ fexists(l.file) }">
        <MvASSIGN NAME = "var" VALUE = "{ file_append(l.file, 'data', l.message) }">
    <MvELSE>
        <MvASSIGN NAME = "var" VALUE = "{ file_create(l.file, 'data', l.message) }">
    </MvIF>
</MvFUNCTION>