Returning the name of a caller function?

Hi all,

I'm sure there is a way to do this (perhaps with FunctionInfo), but I cannot figure it out yet. I would like to determine the name of a function that calls another function.

Example code below: if call "foo()" I should see "foo" printed to the history window, and if I call "bar()" I should see "bar" on the history window.

function foo()
  ///do stuff
  subfunction()
end

function bar()
  ///do other stuff
  subfunction()
end


function subfunction()

   print whocalledme() ////<---what should this code be?
   
end

 

You can start from

GetRTStackInfo(0) and peel the last name in the list.