SYS_FileReadLine Function


Returns the next line of a file from a target machine.


bDidRead = SYS_FileReadLine (hFile, sLine)
Variable Description
bDidRead Whether a line was read. BOOLEAN.
hFile The handle of the file to read a line from. HFILE.
sLine A variable to hold the line. STRING.


  • SYS_ FileReadLine is executed by the agent process, not the Silk Test Classic process; but it is essentially the same as FileReadLine. To affect the host process, use the function with the hHost notation or machine handle operator. For more information about the machine handle operator and hHost, see Machine handle operator.

  • SYS_ FileReadLine reads the next line of a file and returns the contents of the line in sLine. Typically, you open a file with SYS_FileOpen, and then read it line by line with SYS_ FileReadLine until FALSE is returned.

  • SYS_ FileReadLine returns TRUE if a line was read, or FALSE if the end of the file was encountered.

  • SYS_ FileReadLine modifies the sLine variable. Any previous value in sLine is discarded.

  • SYS_ FileReadLine automatically handles cross-platform end-of-line differences.

  • You can get a handle to a file (an HFILE) by calling the SYS_FileOpen function with the FM_READ filemode data type. An exception is raised if an invalid file handle is specified. You can read from a file opened in file mode FM_UPDATE, in order to begin overwriting the file in the middle instead of at the beginning. See the example under FileReadLine function.

  • 4Test recognizes that it has reached the end of a file (EOF) by no longer reading that file – in other words, by receiving a null string. It does not read any special character at the EOF.

  • For Silk Test Classic, EOF is indicated by a FALSE bDidRead return and a null string is indicated by a TRUE bDidRead return and a null string.

  • This function can handle line lengths up to 4K characters.

  • This function is not designed for local access.


[ ] HFILE hFile
[ ] STRING sLine
[-] testcase FileReadExample ()
	[ ] hFile = SYS_FileOpen ("mydata.txt", FM_READ)
	[-] while (SYS_FileReadLine (hFile, sLine)) 
		[ ] // statements to process this line
	[ ] SYS_FileClose (hFile)