FileReadMessage() function
- Last UpdatedJul 22, 2024
- 1 minute read
Reads a specified number of bytes (or one line) of string data from a file.
Syntax
[result = ] FileReadMessage (filename, offset, messagetag, charstoread)
Parameters
filename
Name of the file to read the data from. A literal string value, a message tagname, or a string expression.
offset
Location (in bytes) in the file to start reading from. A literal integer value, integer tagname, or integer expression.
messagetag
Message tagname that receives the first line or number of bytes from the file. Enclose the tagname with double quotes when using the function within the Industrial Graphics Editor Script Editor.
charstoread
Number of bytes to read from the file. Set it to 0 to read until the next line feed (LF) character. A literal integer value, integer tagname, or integer expression.
Return value
Contains the new byte position after the read. You can use this for subsequent reads from the file.
Example(s)
This script reads the first line of data in the file c:\Data\File.txt to the message tagname MsgTag.
FileReadMessage ("c:\Data\File.txt",0,MsgTag, 0);
FileReadMessage ("c:\Data\File.txt",0,"InTouch:MsgTag", 0);