Open – Argox PA-20 Programming Guide User Manual

Page 44

Advertising
background image

PT-20 Programming Guide

42

Description: The lseek function moves the file pointer of a DAT file whose

file handle is specified in the argument fd to a new position

within the file. The new position is specified with an offset byte

address to a specific origin. The offset byte address is specified

in the argument offset which is a long integer. There are 3

possible values for the argument origin.

The values and their interpretations are listed below.

Value of origin

Interpretation

1

beginning of file

0

current file pointer position

-1

end of file

Returns: When successful, lseek returns the new byte offset address of the

file pointer from the beginning of file. In case of error, lseek

returns a long value of -1L and an error code is set to the global

variable fErrorCode to indicate the error condition encountered.

Possible error codes and their interpretation are listed below.

fErrorCode: 2:File specified by fd does not exist.

9:Illegal offset value.

10:Illegal origin value.

15:New position is beyond end-of-file.

open

Purpose: Open a DAT file and get the file handle of the file for further

processing.

Syntax: int open(char *filename);

Example call:

if (fd = open(“C:\\data\\store.dat”)>0)

_puts(“store.dat opened!”);

Includes:

#include “SDK.h ”

Description: The open function opens a DAT file specified by filename and

gets the file handle of the file. A file handle is a positive integer

(excludes 0) used to identify the file for subsequent file

manipulations on the file. If the file specified by filename does

not exist, it will be created first. If filename exceeds 8 characters,

it will be truncated to 8 characters long. After the file is opened,

the file pointer points to the beginning

of file.

Returns: If open successfully opens the file, it returns the file handle of the

file being opened. In case of error, open will return an integer value of -1

Advertising