| **Navigation:**  [[introduction.htm|Language Reference]] > 13 - Built-in Functions >====== PUSHERRORS (write error information) ====== | [[poperrors return error information .htm|{{btn_prev_n.gif|Previous page}}]][[introduction.htm|{{btn_home_n.gif|Return to chapter overview}}]][[put re write record .htm|{{btn_next_n.gif|Next page}}]] | | || **PUSHERRORS(** **)** {{blk2blue.jpg|blk2blue.jpg}} | **PUSHERRORS** | Writes the last error information to an internal memory stack. | The **P****USHERRORS** procedure writes the current error states of the current thread's ERRORCODE(), ERROR(), FILEERRORCODE(), FILEERROR(), ERRORFILE(), the C library //errno// variable, and the current Windows error code returned by the GetLastError() API function. POPERRORS is used to restore the error states originally saved by **PUSHERRORS**. The main purpose of these functions is to save errors states and then check them later, after performing some additional code that can potentially change them. **PUSHERRORS** and POPERRORS works using the LIFO (last in, first out) stack convention. The maximum depth of the stack is dependent on available memory. Because ERRORCODE(), ERROR(), etc. are thread dependent, **PUSHERRORS** and POPERRORS statements that are called from different threads are independent of each other, and allocate a different memory stack for each thread. **Example:** **    PROGRAM** **    MAP** **     InitialErrors()** **    END** **TESTFILE    FILE,DRIVER('DOS')** **             RECORD** **f1            BYTE** **             END** **            END** **    CODE** **    !file processing and initialization here** **    OPEN(testfile)   !forcing an error** **   ****PUSHERRORS()** **    !additional code here** **    InitialErrors** **InitialErrors       PROCEDURE** **ERRORCODEVAR        LONG** **ERRORVAR            CSTRING(255)** **FILEERRORCODEVAR    LONG** **FILEERRORVAR        CSTRING(255)** **ERRORFILEVAR        CSTRING(255)** **Window WINDOW('Error Report'),AT(,,362,128),FONT('MS Sans Serif',8,,FONT:regular,CHARSET:ANSI),SYSTEM, |** **         GRAY** **       PROMPT('ERRORCODE:'),AT(9,10),USE(?Prompt1)** **       STRING(@N_4),AT(97,10,43,10),USE(ERRORCODEVAR)** **       PROMPT('ERROR:'),AT(9,25),USE(?Prompt2)** **       STRING(@s40),AT(96,25),USE(ERRORVAR)** **       PROMPT('FILEERRORCODE:'),AT(9,40),USE(?Prompt3)** **       STRING(@N_4),AT(95,40),USE(FILEERRORCODEVAR)** **       PROMPT('FILEERROR:'),AT(9,55),USE(?Prompt4)** **       STRING(@S40),AT(95,55),USE(FILEERRORVAR)** **       PROMPT('ERRORFILE:'),AT(9,70),USE(?Prompt5)** **       STRING(@S40),AT(95,71),USE(ERRORFILEVAR)** **     END** **        CODE** **        POPERRORS()** **        ERRORCODEVAR     = ERRORCODE()     !will return 2** **        ERRORVAR         = ERROR()         !will return "File Not Found"** **        FILEERRORCODEVAR = FILEERRORCODE()** **        FILEERRORVAR     = FILEERRORCODE()** **        ERRORFILEVAR     = ERRORFILE()     !will return "TESTFILE"** **        OPEN(WINDOW)** **         ACCEPT** **          DISPLAY** **         END** **See Also:** [[poperrors return error information .htm|POPERRORS]]