Re: routine_id mishaps
- Posted by xanax at bellsouth.net Dec 14, 2002
- 360 views
OK folks, Here is the ammended code! good luck with trace trace(1) constant TRUE = 1, FALSE = 0 sequence types, handles, rps handles = {} rps = {} types = {} integer proc, func proc = 0 func = 1 global procedure add_routine (integer pf, object handle, integer rp) integer pos pos = find (handle, handles) if pos then types[pos] = pf rps[pos] = rp else handles = append(handles, handle) types = append(types, pf) rps = append(rps, rp) end if end procedure global function call_routine (object handle, sequence arg) integer pos pos = find (handle, handles) if pos then if types[pos] then return {TRUE, call_func (rps[pos], arg)} else call_proc (rps[pos], arg) return {TRUE} end if else return {FALSE} end if end function procedure my_proc (integer a, integer b) puts (1, {a,b}) end procedure add_routine (proc,"my_proc", routine_id ("my_proc")) function my_func (integer a, integer b) return "HellO!" end function add_routine (func, "my_func", routine_id ("my_func")) sequence result result = call_routine ("my_proc", {'a','b'}) -- result is now {TRUE} result = call_routine ("my_func", {'a','b'}) -- result is now {TRUE, "HellO!"} result = call_routine ("my_house", {'a','b'})