I have a Session Method that allows me to enter some Text as a parameter to insert into a record:
Sub MyMethod (note As Text)
<Start of code that inserts stuff into a record>
some Text + EndOfLine +_
note + EndOfLine +_
more Text
<End of code that inserts stuff into a record>
End Sub
I’d like to be able to have MyMethod insert CurrentMethodName of the calling Method as the note you see above, if note is empty:
Sub MyMethod (note As Text = CurrentMethodName)
... same as previous code ...
End Sub
But Xojo won’t allow that during compilation. So for now, wherever I use MyMethod (note As Text), I must manually fill in CurrentMethodName for its parameter when I want that:
MyMethod(CurrentMethodName)
That works fine. I’m just trying make that the default when no parameter is supplied.
Thanks, Julian. I saw that thread earlier, but wanted to see if I could just do it more simply. I thought maybe there was a trick that allows a Method to accept CurrentMethodName as a default value for a Parameter (As String or As Text).
I eventually decided to go ahead and handle this by creating a global function using the code in the German forum thread mentioned by Tobias. Very similar to the code cited by Julian.
Just FYI, testing with 10000 calls, using the exception method is approx 15000x slower than just passing the method name in when measuring in the debugger. In a 64-bit compiled app, it’s about 32000x slower.
Do you think a future version of Xojo will have a built-in CallingMethodName method?[/quote]
No. CurrentMethodName is literally a constant that gets rendered at the beginning of each methods code.