Programming Guide |
Gets the error returned by the last call to a file I/O function
int sm_fio_error(void);
- 0 Success.
- -1
SMFIO_INVALID_HANDLE
: Invalid file handle.
- -2
SMFIO_HANDLE_CLOSE
: Handle points to closed file.
- -3
SMFIO_EOF
: Already at end of file.
- -5
SMFIO_INVALID_MODE
: Invalid mode specified for open operation.
- -6
SMFIO_NO_HANDLES
: All available file handles currently in use.
- -7
SMFIO_OPEN_ERROR
: Unable to open the file—for example, because it does not exist or is protected.
- -8
SMFIO_FIELD_ERROR
: Nonexistent field.
- -9
SMFIO_FILE_TRUNCATE
: Array not large enough to accept all file data; partial read was successful.
sm_fio_error
gets the last value returned by a file I/O function. Use this function after calling sm_fio_gets and sm_fio_handle, which respectively return an empty string andNULL
when an error occurs. In both cases, you must callsm_fio_error
to determine the actual cause of the error.Note: Because the same error code variable is shared by all JPL file I/O routines, you should call
sm_fio_error
before making any other I/O operations with Panther library functions.
/* Write the contents of an ASCII file to a single- *
* line text array. The file stream handle was *
* obtained earlier by a call to sm_fio_open() *
*/
proc getStr()
{
vars str, occurNo, err, fileStream, maxOccurs
call sm_fio_error_set(0)
/* get array size */
maxOccurs = @widget("comments")->max_occurrences
/* get file stream handle sent from previous dialog */
receive BUNDLE f_handle DATA fileStream
/* loop through array occurrences */
for occurNo = 1 && err = 0 \
while (err == 0 && occurNo <= maxOccurs)
{
/* get the next string in file stream */
str = sm_fio_gets(fileStream, 32)
/* check for error condition like EOF */
if (str == "")
{
err = sm_fio_error()
}
/* read string into occurrence */
comments[occurNo] = str
}
/* close the file stream when done */
call sm_fio_close(fileStream)
return
}