SEEK filevar [,offset [,relto]] [THEN statements] [ELSE statements]
|filevar||A file variable name used to refer to the file in Caché MVBasic. This filevar is obtained from OPENSEQ.|
|offset||Optional — A positive or negative integer count of bytes used to reposition the file pointer relative to the relto position. By default, offset is 0.|
|relto||Optional — A flag indicating the pointer position is determined relative to some location. The available values are: 0=relative to the beginning of the file; 1=relative to the current pointer position; 2=relative to the end of the file. The default is 0.|
The SEEK statement is used to position the sequential file pointer in a file that has been opened for sequential access using OPENSEQ.
By default, SEEK repositions the file pointer to the beginning of the file. SEEK can be used to increment or decrement the file pointer from its current position, or from the beginning or end of the file.
You can determine the current position of the file pointer using the STATUS statement.
You can optionally specify a THEN clause, an ELSE clause, or both a THEN and an ELSE clause. If the pointer reposition is successful, the THEN clause is executed. If pointer reposition fails (usually because the specified position is beyond the limits of the file), the ELSE clause is executed and the pointer position remains unchanged. The statements argument can be the NULL keyword, a single statement, or a block of statements terminated by the END keyword. A block of statements has specific line break requirements: each statement must be on its own line and cannot follow a THEN, ELSE, or END keyword on that line.
You can use the STATUS function to determine the status of the pointer reposition operation, as follows: 0=success; -1=pointer reposition failed because either position is beyond the limits of the file or the file is not open.