seek

Typecommand
DictionaryLCS
LibraryLiveCode Script
Syntax
seek {to | rel[ative]} <byteNumber> in file <filePath>
Summary

Locates a position in a file, to be used by the read from file and write to file commands.

Introduced1.0
OSmac, windows, linux, ios, android
Platformsdesktop, server, mobile
Parameters
NameTypeDescription
byteNumber

An integer representing the position in the file.

filePath

The filePath specifies the name and location of the file you want to seek in. It must be the same as the path you used with the open file command. The filePath is case-sensitive, even on platforms where file names are not case-sensitive.

Example
seek to 100 in file "test.txt"
seek relative -10 in file "test.txt"
put specialFolderPath("desktop")  & "/test.txt" into tFile
open file tFile for write
write "123456789--" to file tFile
seek to 9 in file tFile
write "10" to file tFile
close file tFile
RelatedCommand: close file, read from file, write to file
Glossary: command, byte
Keyword: file, relative
Description

Use the seek command to prepare to read from or write to an open file at a specific position in the file.

The next read from file or write to file command will start reading or writing at the position specified by the seek command.

Theform sets the file position to byteNumber bytes from the start of the file. Theform sets the file position to byteNumber bytes from the current position. The position is set by either a previous seek command, or a read from file or write to file command.

Tagsfile system