Nasal library/io: Difference between revisions

Jump to navigation Jump to search
→‎seek(): Add example
(→‎seek(): More doc)
(→‎seek(): Add example)
Line 286: Line 286:
|param3 = whence
|param3 = whence
|param3text = Specifies position to set the offset from. Must be one of {{func link|SEEK_SET}} (beginning of file), {{func link|SEEK_END}} (end of file), or {{func link|SEEK_CUR}} (current pointer position).
|param3text = Specifies position to set the offset from. Must be one of {{func link|SEEK_SET}} (beginning of file), {{func link|SEEK_END}} (end of file), or {{func link|SEEK_CUR}} (current pointer position).
|example1 =  
|example1 = var path = getprop("/sim/fg-root") ~ '/Nasal/geo.nas';
var file = io.open(path, "r"); # open file
var len = 15;
var buf = bits.buf(len);
io.seek(file, 122, io.SEEK_SET); # set to the desired position
io.read(file, buf, len); # read file
print(buf); # prints "geo.Coord class"
io.close(file); # close file
}}
}}


Navigation menu