PT-20 Programming Guide
46
fErrorCode
:
2:File handle is NULL.
7:fd is not a file handle of a previously opened file.
write
Purpose
:
Write a specified number of bytes to a DAT file.
Syntax
:
int write(int fd, char *buffer, unsigned count);
Example call
:
write(fd, data_buffer,100);
Includes
:
#include “SDK.h ”
Description
:
The write function writes the number of bytes specified in the
argument count from the character array buffer to a DAT file
whose file handle is fd. Writing of data starts at the current
position of the file pointer, which is incremented accordingly
when the operation is completed.
If the end-of- file condition is encountered during the operation,
the file will be extended automatically to complete the operation.
Returns
:
The write function returns the number of bytes actually written to
the file. In case of error, write returns an integer value of -1 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 handle is NULL.
7:fd is not a file handle of a previously opened file.
10:No more free file space for file extension.
writeln
Purpose
:
Write a line terminated by a null character (\0) to a DAT file.
The null character is also written to the file. After writing in, file
position will update.
Syntax
:
int writeln(int fd, char *buffer);
Example call
:
writeln(fd, data_buffer);
Includes
:
#include “SDK.h ”
Description
:
The writeln function writes a line terminated by a null character
from the character array buffer to a DAT file whose file handle is
fd. Characters are written to the file until a null character (\0) is
encountered. The null character is also written to the file. Writing
of data starts at the current position of the file pointer, which is
incremented accordingly when the operation is completed. If the
end-of-file condition is encountered during the operation, the file
will be extended automatically to complete the operation.
Returns
:
The writeln function returns the number of bytes actually written