[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
+---------------------------------+
|             FERROR              |
+---------------------------------+
FERROR()

-----------------------------------
Returns zero if last low-level file function did not cause an error.
Return value - Numeric
-----------------------------------

If the previous function was not successful, a positive value is
returned.  The following is a list of values that may be returned by
FERROR() and the cause of the error:

        2       File not found

        4       Too many files open (out of handles)

        5       Access denied

        6       Invalid file handle given

        8       Out of memory

        25      Seek error (can't seek before the start of a file)

        29      Disk full

        31      Error opening file or general failure (EOF encountered)

+---------------------------------+
|         Program Example         |
+---------------------------------+
The example below creates and opens temporary file for data entry.  If
file is created successfully, program creates input window where you can
enter first name, last name and position.  This information is then
written to temporary file.  FWRITE() does not place carriage return at
end of string. FPUTS() places carriage return at end of string.

SET TALK OFF
CLEAR
tmpfile = SYS(3)                                     && Create a temporary file name
handle = FCREATE(tmpfile) && Open the temporary file

IF handle < 0               && Error generated creating file
        DO CASE                                                      && Determine which error
                        CASE FERROR() = 4
                                reason = 'Too many files open (out of handles)'
                        CASE FERROR() = 5
                                reason = 'Access denied'
                        CASE FERROR() = 8
                                reason = 'Out of memory'
                        CASE FERROR() = 29
                                reason = 'Disk full'
            CASE FERROR() = 31
                        reason = 'General Failure'
                ENDCASE
        *** Display the error ***
        WAIT WINDOW 'Can't create file: '+ reason NOWAIT
        RETURN
ELSE                         && File created successfully
        DEFINE WINDOW wingets FROM 10,20 TO 18,60 ;
                CLOSE FLOAT SHADOW SYSTEM ;
                COLOR SCHEME 8 TITLE ' Name Entry '
        ACTIVATE WINDOW wingets
        @ 1,5 SAY "First Name:" GET fname DEFAULT SPACE (15)
        @ 3,5 SAY "Last Name :" GET lname DEFAULT SPACE (15)
        @ 5,5 SAY "Position  :" GET pos DEFAULT SPACE (15)
        READ
        =FWRITE(handle,'First name: ')  && Output info entered by the user
        =FPUTS(handle,fname)
        =FWRITE(handle,'Last name: ')
        =FPUTS(handle,lname)
        =FWRITE(handle, 'Position: ')
        =FPUTS(handle,pos)
        =FCLOSE(handle)                                           && Close the file
        DEACTIVATE WINDOW wingets
        WAIT 'Press a key to view the file' WINDOW
ENDIF
IF !WEXIST('wingets')
        DEFINE WINDOW wingets FROM 10,20 TO 18,60 ;
                CLOSE FLOAT SHADOW SYSTEM ;             COLOR SCHEME 8 TITLE ' Name Entry '
ENDIF

MODIFY FILE (tmpfile) NOWAIT WINDOW wingets && View the file
CLEAR WINDOW  &&Remove the window

-----------------------------------

See Also:  FCHSIZE(), FCLOSE(), FCOUNT(), FCREATE(), FEOF(), FFLUSH(),
FGETS(), FOPEN(), FPUTS(), FREAD(), FSEEK(), FSIZE(), FWRITE()

-----------------------------------

See Also: FCHSIZE() FCLOSE() FCOUNT() FCREATE() FEOF() FFLUSH()
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson