Readln, Remove – Argox PA-20 Programming Guide User Manual
Page 46
![background image](https://www.manualsdir.com/files/772043/content/doc046.png)
PT-20 Programming Guide
44
Purpose:
Read a line terminated by a null character “\0” from a DAT file.
Syntax: int readln(int fd, char *buffer, unsigned max_count);
Example call: readln(fd, buffer, 50);
Includes:
#include “SDK.h ”
Description: The readln function reads a line from the DAT file whose file
handle is fd and stores the characters in the character array buffer.
Characters are read until end-of-file encountered, a null character
(\0) encountered, or the total number of characters read equals the
number specified in max_count. The readln function then returns
the number of bytes actually read from the file. The null character
(\0) is also counted if read. If the readln function completes its
operation not because a null character is read, there will be no null
character stored in buffer. Reading starts at the current position of
the file pointer, which is incremented accordingly when the
operation is completed.
Returns: The readln function returns the number of bytes actually read
from the file (includes the null character if read). In case of error,
readln 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.
Purpose: Delete file.
Syntax: int _remove(char *filename);
Example call: if (_remove(C:\\data\\
store.dat) _puts(“store.dat deleted”);
Includes:
#include “SDK.h ”
Description: Delete the file specified by filename. If filename exceeds 8
characters, it will be truncated to 8 characters long. If the file to be
deleted is a DBF file, the DBF file and all the index (key)
files associated to it will be deleted altogether.
Returns: If remove deletes the file successfully, it returns an integer value
of 1. In case of error, remove will return an integer value of 0 and
an error code is set to the global variable fErrorCode to indicate
the error condition encountered. Possible error codes and their
interpretations are listed below.