Product Documentation
Cadence SKILL Language Reference
Product Version IC23.1, November 2023

fileSeek

fileSeek( 
p_port 
x_offset 
x_whence 
) 
=> t / nil

Description

Sets the position for the next operation to be performed on the file opened on a port. The position is specified in bytes.

Arguments

p_port

Port associated with the file.

x_offset

Number of bytes to move forward (or backward with negative argument).

x_whence

Valid Values:

0 Offset from the beginning of the file.

1 Offset from current position of file pointer.

2 Offset from the end of the file.

Value Returned

t

The operation was successfully completed.

nil

The file does not exist or the position given is out of range for an input file.

Examples

Let the file test.data contain the single line of text:

0123456789 test xyz
p = infile("test.data")
=> port:"test.data"
fileTell(p)              
=> 0
for(i 1 10 getc(p))      
=> t   ; Skip first 10 characters
fileTell(p)              
=> 10
fscanf(p "%s" s)         
=> 1   ; s = "test" now
fileTell(p)              
=> 15
fileSeek(p 0 0)
=> t
fscanf(p "%d" x)
=> 1   ; x = 123456789 now
fileSeek(p 6 1)          
=> t
fscanf(p "%s" s)         
=> 1   ; s = "xyz" now

Related Topics

fileTell

isFile

isFileName


Return to top
 ⠀
X