ONEXIT

Top  Previous  Next

Syntax

ONEXIT(fn as UINT,pData as POINTER)

Description

Adds a subroutine to the on-exit list.

Parameters

fn - Address of subroutine.

pData - Pointer to user data or NULL

Return value

None

Remarks

The functions in the on-exit list are called in LIFO (Last In First Out) order when your program exits. The DECLARE for an on-exit function must include one parameter of type POINTER. A subroutine can be added more than once.

Example usage

ONEXIT(&myfunc1,NULL)
ONEXIT(&myfunc2,NULL)
ONEXIT(&myfunc1,"hello")
END
 
SUB myfunc1(pData as POINTER)
IF pData = NULL
    MESSAGEBOX 0,"myfunc1","TEST"
ELSE
    MESSAGEBOX 0,"myfunc1",#<STRING>pData
ENDIF
RETURN
ENDSUB
 
SUB myfunc2(pData as POINTER)
MESSAGEBOX 0,"myfunc2","TEST"
RETURN
ENDSUB