Tip of the day: Where are we in the code?
For logging bugs it may be useful to know where you are. For example you may want to log a problem and include where you are in the code.
You can query the window or control class names with Introspection. With me you refer to the control or with self you refer to current window. The Xojo language adds a CurrentMethodName constant to each method.
EventHandler Sub Pressed()
// query which window we are inside:
System.DebugLog "Window Class Name: "+Introspection.GetType(Self).name
System.DebugLog "Window Title: "+Self.Title
// which control we are inside:
System.DebugLog "Control Class Name: "+Introspection.GetType(Me).name
System.DebugLog "Control Name: "+Me.name
// current method as constant
System.DebugLog "Current Method Name: "+CurrentMethodName
// and use exception to get caller
System.DebugLog "Caller Name: "+GetCallerName
End EventHandler
Here is a little helper function to query the caller name by raising and catching an exception:
Module UtilModule
Function GetCallerName() As String
#Pragma BreakOnExceptions False
Try
Dim r As New RuntimeException
Raise r
Catch r As RuntimeException
dim names() as string = r.Stack
// 0 = Raise
// 1 = GetCallerName
// 2 = Method calling GetCallerName
// 3 = Caller
Return names(3)
End Try
End Function
End Module
The BreakOnExceptions pragma avoids the IDE stopping at that line.
Let us know if you have questions.