FileWrite is a built-in function that writes a string to a specified text file. If the file does not exist, it will be created when the function is executed.
|Function||Group||Execution||Windows||Embedded||Thin Client||Mobile Access|
|FileWrite||File||Synchronous||Supported||Supported||Supported (see “Notes” below)||Not supported|
- The name of the text file.
By default, the file must be located in your project folder (i.e., the folder that contains the file projectname.APP), on the computer that host the project runtime server. If the file is or should be located in another folder, specify the complete file path.
- The text to be written to the file.
- A numerical flag indicating how the text should be written to the file:
Value Description 0 Create a new ASCII file with the specified file name. If the file already exists, overwrite it. 1 Append to an existing ASCII file with the specified file name. If the file does not exist, create it. 2 Create a new Unicode (UTF-16LE) file with the specified file name. If the file already exists, overwrite it. 3 Append to an existing Unicode (UTF-16LE) file with the specified file name. If the file does not exist, create it.
This parameter is optional; if no value is specified, or if the specified value is not one of the accepted values described in the table above, the default value is 0.
|0||Function successfully executed.|
|-2||Failed to open file. Either the drive is write-protected or the file name is invalid.|
If this function is called in a project screen on a thin client, it will still write to the specified file in the project folder on the computer that hosts the project runtime server. You cannot use this function to write to a file on the thin client.
FileWrite("est.txt","This is a test.")
FileWrite("est.txt","This is a test.",1)
FileWrite("C:UsersMyUserDocumentsest.txt","This is a test.",3)