Read/Write File
Reads text or binary data from a file, or writes data to a file. File editors are registered in Settings > File Editor.
File Editor
Select the file editor to use.
Commands
- Read (default): Reads the file and stores its content in a variable.
- Read Line: Reads one line from the file and stores it in a variable. After reading, the cursor moves to the next line automatically.
- Write: Writes text or binary data to the file. Creates the file if it does not exist.
- Append: Appends data after the existing content of the file. Creates the file if it does not exist.
- Clear All: Deletes all content of the file.
- Close File: Closes the open file.
- Is End of File: Stores in a variable whether the cursor has reached the end of the file.
Fields
File Path
For Read and Read Line, select the file to read from the files uploaded to the project. For
Write and Append, enter the path of the file to write, or pick it in the file browser (for example,
C:\Users\me\file or /home/me/file); both slashes and backslashes are accepted,
and surrounding spaces and quotes are removed automatically. The field is not displayed for Clear All,
Close File, and Is End of File.
File Mode
Select the data format, Text (default) or Binary (byte array). Displayed only when Command is Read, Write, or Append.
Clear Content
Select whether the existing content is deleted before writing. The default is on. Displayed only when Command is Write.
Cursor Position
Select where to read or write from: Current Position, Beginning (default), or Set Position. Displayed when Command is Read, Read Line, or Write with Clear Content off. When Set Position is selected, enter the byte position (0 to 4294967295) in Cursor Position Input.
Size to Read
Select To End (default) or Set Size. When Set Size is selected, enter the number of bytes (1 to 4294967295, default 10) in Input Size to Read. Displayed only when Command is Read.
Write Content
Enter the data to write: text in Text mode or a byte array in Binary mode. Displayed only when Command is Write or Append.
Auto Line Break
Select whether a line break is inserted after the existing content before appending. The default is off. Displayed only when the file mode is Text and Command is Append.
Output variables
- Read Content: The variable that receives the data read. Select a Text variable in Text mode or a Byte Array variable in Binary mode. Displayed when Command is Read or Read Line.
- End of File (EOF): A Digital variable that receives whether the cursor has reached the end of the file. Displayed only when Command is Is End of File.