; ; @ANO_SCRIPT_NAME function_hook ; @ANO_SCRIPT_VERSION 0.0.1 ; @ANO_SCRIPT_DESCRIPTION Simple function hook example ; ; @ANO_FLAGS_USE_PROTOS [ ] ; @ANO_FLAGS_VAR_NAME_SUBS [ ] ; @ANO_FLAGS_VAR_WARN_UNUSED [ ] ; ; Copyright (c) 2016-2026, Jani Salonen ; All rights reserved. ; ; Ano script supports function hooks, which is like constructor and destructor ; of a function. Also main block can have finalize block which runs when main ; program terminates. ; main [exit: 0] { &my_func (1, 2) } finalize { ; This hook is called when main program calls exit(). ; print "\n" \ "Finalize block is started automatically when exit function" \ " is called.\nThis block does not pass to control to main" \ " block anymore.\n" } function my_func [entry: my_func_entry, return: my_func_ret] (_var1, _var2) { ; Entry hook is called here. ; ; This is what this function is for: ; print "This is function with hooks.\n" ; Return hook is called at the end of the function, which is here. ; } hook my_func_entry { ; Hook has access to function parameters: ; print " * function is about to start, _var1 value is " . _var1 . ".\n" } hook my_func_ret { ; Hook has access to function parameters: ; print " * function ends, _var2 value is " . _var2 . ".\n" }