Re: routine_id (was sethandler() help please)
- Posted by Mike Nelson <MichaelANelson at WORLDNET.ATT.NET> Sep 05, 2003
- 330 views
Pete: Let me try this again with comments. function Eu_routine_id(sequence x) -- wraps the builtin routine_id() return routine_id(x) -- returns the routine_id of x, or -1 if x is invalid -- (the routine_id() built into the interpreter) end function global function routine_id(sequence x) -- this definition redefines (overrides) the builtin routine_id integer rid rid= Eu_routine_id(x) -- get the origninal routine id via the Eu_routine_id() warpper function. if rid >=0 then return rid end if -- if valid, return it ?1/0 -- if not, crash instead of returning -1 end function integer foo_ID,bar_ID procedure foo() end procedure foo_ID=routine_id("foo") -- calls my routine_id() and assigns foo()'s ID bar_ID=routine_id("bar") -- calls my routine_id() and crashes, since bar() is not defined. This is the standard technique for redefining a Eu builtin. It's documented somewhere but I've been unable to locate it in refman.doc. -- Mike