
The function block FS_WRITE writes data to a file system.
Warning: Existing files are overwritten without warning.
The file system must have been initialized beforehand using FS_INIT. All operations are performed asynchronously per configured storage medium.
A positive edge triggers the data to be written to the storage medium.
Defines the device from which files should be accessed. The device is used per project and can be managed in the context menu under Project External Storage.
Specifies the path to the file on the storage medium. The path corresponds to a Unix file path in UTF-8 format, if this is supported. The path is represented as follows:
Folder/Subfolder/File.txt
Defines the data that should be written.
Specifies the mode in which the file should be written. Possible modes are:
| Mode | Description |
|---|---|
| "r" | Opened for reading only. Places the file pointer at the beginning of the file. |
| "r+" | Opened for reading and writing. Places the file pointer at the beginning of the file. |
| "w" | Opened for writing only. Places the file pointer at the beginning of the file. Deletes the content of the file. If the file does not exist, it is created. |
| "w+" | Opened for writing and reading. Places the file pointer at the beginning of the file. Deletes the content of the file. If the file does not exist, it is created. |
| "a" | Opened for writing only. Places the file pointer at the end of the file. If the file does not exist, it is created. The data is appended. |
| "a+" | Opened for writing and reading. Places the file pointer at the end of the file. If the file does not exist, it is created. The data is appended. |
| "x" | Opened for writing only. Places the file pointer at the beginning of the file. If the file exists, it is aborted. |
| "x+" | Opened for writing and reading. Places the file pointer at the beginning of the file. If the file exists, it is aborted. |
| "c" | Opened for writing only. Places the file pointer at the beginning of the file. If the file does not exist, it is created. Overwrites the content of the file. |
| "c+" | Opened for writing and reading. Places the file pointer at the beginning of the file. If the file does not exist, it is created. Overwrites the content of the file. |
If the input is true when writing, the UTF-8 Byte Order Mark is appended at the beginning of the file. This only happens if the file is overwritten or created new. If the BOM was not written at the beginning of the file, it cannot be added later.
The output returns a pulse upon success to perform the next operation. The pulse occurs when the process ends, even if an error has occurred.
Returns the number of bytes written. The state is stored for later use.
In case of an error, returns a text with an error message. This is FALSE if no error has occurred. The state is stored for later use.
Possible causes: