Type/to search
Built-in Functions
Global
Log
Market
Trade
Account
Futures
Exchange
IO
Network
Storage
Threads
TA
Talib
OS
os
File
File.close
File.puts
File.printf
File.flush
File.tell
File.seek
File.eof
File.read
File.write
File.getline
File.toString
ListFilesResult
FileStat
Structures
Built-in Variables and Constants
Conventions
Exchanges

Check if the file pointer has reached the end of file.

eof()

Examples

Read file line by line until end of file.

javascript
function main() { let file = os.open("data.txt", "r") let lineCount = 0 while (!file.eof()) { let line = file.getline() if (line !== undefined) { lineCount++ Log("Line", lineCount + ":", line) } } Log("Total lines:", lineCount) file.close() }

Returns

TypeDescription

bool

Returns true if end of file has been reached, otherwise returns false.

See Also

Remarks

Used to determine whether all content has been read when reading a file. It returns true only after a read has hit the end of file, e.g. getline() returned undefined, read(size) got no data, or read() without arguments read the rest of the file; seek() resets it to false.