Function Read
Function Read
Function: read
Function Prototype
Note
Parameter Description
Return Value
Error Handling
Example
Result
This function enables you to read data from the opened file.
Function Prototype
File_object.read([size])
Note
When using the Read function, you need to open the existing file in a read mode through the
Open function.
If the length of the data needed to be read exceeds the maximum, you need to read all the
data of the file.
Parameter Description
Parameter Description
size Length of the data to be read. By default, the length of the data to be read is
the maximum data length of the file. The unit is byte, and the value must be
greater than 0.
This parameter is optional. If it is not set, all the data of the file is read by
default.
Return Value
The return value is the data read from the file.
https://10.98.117.5:31943/hedex/hedex.do?lib=OMC&id=omc.Scriptapp.mainpage&topicid=p_read_file_a&locale=en-us 1/2
3/25/23, 4:59 PM Function: read
Error Handling
None
Example
fp = Open("Hello.txt",'r') #Assume that the content of the Hello.txt file is 12345.
str = fp.read()
Print(str)
Result
12345
https://10.98.117.5:31943/hedex/hedex.do?lib=OMC&id=omc.Scriptapp.mainpage&topicid=p_read_file_a&locale=en-us 2/2