AddExitHandler

Far Manager Macro System

AddExitHandler


mf.AddExitHandler (handler)

Parameters:
  handler:  function

Returns:
  nothing

Description:
  1. This function adds a handler that will be called at the end
     of the macro execution.
  2. The handler will be called both in the case of normal macro
     completion and in the case of error completion.
  3. If multiple handlers were added during macro execution then they
     will be called in the order reverse to the order of their adding.

Usage example:
  local fp = assert(io.open("some file.txt"))
  mf.AddExitHandler(function() fp:close() end)
  -- use fp; return from multiple places; do not care about closing fp

See also:
Restrictions in the use of some functions