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

Move the file pointer to a specified position.

seek(offset, whence)

Examples

Read characters in reverse order.

javascript
function main() { let str = "Hello FMZ!" let file = os.open("data.txt", "w+") file.write(str) // If i > str.length, seek() throws an exception (invalid argument) for (let i = 1; i <= str.length; i++) { file.seek(-i, 2) let data = file.read(1) Log("i:", i, ", data:", data) } file.close() }

Returns

TypeDescription

number

Returns the new file pointer position.

Arguments

NameTypeRequiredDescription

offset

number

Yes

Offset (in bytes).

whence

number

Yes

Reference position: 0=beginning of file, 1=current position, 2=end of file.

See Also

Remarks

Used to position the file pointer, the offset parameter can be negative (indicating backward movement).