Programming Guide



sm_fio_error

Gets the error returned by the last call to a file I/O function

int sm_fio_error(void);

Returns

Description

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 and NULL when an error occurs. In both cases, you must call sm_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.

Example

/* 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
}