Re: Functions & Procedure runing stak
- Posted by Senator Dec 01, 2018
- 1629 views
clkeriolet said...
Hello everybody, I search for the name of the euphoria sequence (if there is) containing the stack of nested functions or procedures running in my program (by their name or routine Id) - Any help would be greatly appreciated !
I am not sure if this routine is what you are asking for. Perhaps it will help.
-- --- file qindex.ex by Phil F. --- (lists global & local routines from Euphoria source files --- --- with line numbers) -- --- usage: eui qindex.ex Eusourcefile -- --- or: eui qindex.ex Eusourcefile > keepme.txt -- -- modified to list public and export routines by Kenneth Rhodes include std/io.e integer fn, ch, found, ct, outdev sequence f, test, params, num object l outdev = 1 -- >> usually to console -- params = command_line() if length(params) < 3 then puts(1,"Usage: eui qindex.ex sourcefile > [optional] keepme.txt\n") end if f = params[3] fn = open(f,"r") if fn < 0 then puts(1, "Sorry, could not open " & f & '\n') abort(0) end if ct = 0 puts(outdev, "\n--- " & f & " ---\n") found = 0 while 1 do l = gets(fn) ct += 1 if atom(l) then exit end if --- end of file -- if length(l) < 8 then continue end if --- "function" won't fit -- if length(l) > 100 then l = l[1..100] & '\n' end if test = "" for i = 1 to length(l) do ch = l[i] if not find(ch, " \t") then --- 'non-spaces' only -- test &= ch if equal(test, "--") then continue elsif find(test, {"global","public", "export"}) then test = "" --- skip -- elsif find(test, {"procedure", "function"}) then num = sprintf("%d: ", ct) puts(outdev, num & l) found += 1 elsif length(test) > 9 then -- seen enough! -- continue end if end if end for end while if found = 0 then puts(outdev, "None found\n") end if puts(outdev,"-----------------\n") close(fn)