Register function to run when macro ends

Syntax

atend function [argument]

 

Parameters

function - name of a user-defined or dll function. Can be sub-function.

argument - some value to pass to the function. The function can optionally have one parameter of type int or pointer. Default: 0.

 

Remarks

Sometimes it is important to execute some code when macro ends. Macro can, for example, end on an error. This statement registers function to run when current macro ends.

 

function runs in thread that registered it. When it runs, local variables of current thread's entry function still exist. The _error variable is empty if the macro finished successfully, or contains error info if the macro failed.

 

Registered functions run in LIFO (last-in, first-out) order. atend for same function can be called more than once in thread, but it does not register function again if arg value is the same.

 

Do not use atend in functions that run in special threads and threads created by dll functions.

 

In function don't use end (except to generate warning) and avoid unhandled run-time errors. More info.

 

Examples

atend RestoreCapsLock

int* p=malloc(10); atend free p
...