Quirrel4.41.0

iostream.stream.tell

Method of stream, from module "iostream"
instance.tell(): int

Returns the current stream position

Return value

The cursor's offset from the start of the stream, in bytes.

Notes

seek moves the cursor directly; readn, writen, readblob, writeblob, readobject and writeobject move it by however many bytes they consume or produce. The same method works on a file.

Example

examples/iostream/stream/tell.nut
from "iostream" import blob

let b = blob(4)
println("b.tell() at start =", b.tell()) // starts at 0
b.readn('i')
println("b.tell() after readn('i') =", b.tell()) // advanced by the 4 bytes just read
b.seek(1)
println("b.tell() after seek(1) =", b.tell())
b.writen(1, 'c')
println("b.tell() after writen('c') =", b.tell()) // advanced by the 1 byte just written
Output:
b.tell() at start = 0
b.tell() after readn('i') = 4
b.tell() after seek(1) = 1
b.tell() after writen('c') = 2

See also

tellReturns the current stream position
seekSeeks to the given offset; origin is 'b' (begin), 'c' (current) or 'e' (end)
lenReturns the stream length
streamclass index