B4J Question How to get the name of the subroutine in code

IslandMedic

Member
Licensed User
Longtime User
I am creating a logging app on steroids. Is there a way to pass to my logging sub the name of the subroutine that is issuing the logging call.

sub logger(routinename as string, data as string)
do stuff
end sub

Sub Jump
logger(???,"we are doing stuff"")
end sub

in place of the ??? i would like to auto pass the name of the calling routine in this case "Jump"

thanks

Brad
 

Cableguy

Expert
Licensed User
Longtime User
You can use a global variable in order to store the class name as string, or use the Me keyword, but it's content is not what you expect...
 
Upvote 0

Roycefer

Well-Known Member
Licensed User
Longtime User
Use the jAWTRobot library and call the method robot.B4JCallingThreadStackTraceGet(). If you call this inside your logger sub, the calling sub should be the 2nd or 3rd element in the stack trace array.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…