There are rare instances where the name of a method needs to be returned, such as for identifying the source of an error, etc.
Here is a procedure provided my Microsoft for doing just that, and would be a nice feature to include implement in Mercury.
''' <summary>Returns the name of the calling member (currently active routine, property, or event).</summary> ''' <param name="RoutineName">[Optional] Reserved placeholder for the name of the routine, property, or event from which the call originated. DO NOT PROVDIE A VALUE FOR THIS ARGUMENT - the operating system will provide the correct value during execution of the routine.</param> ''' <returns>Returns a string value containing the routine's name.</returns> ''' <remarks>This routine must be called from within the routine, property, or event from which its name is to be obtained. Returns an empty string value in the event of an error.</remarks> Friend Function GetRoutineName(<System.Runtime.CompilerServices.CallerMemberName> Optional RoutineName As System.String = TextAids.TXT_EMPTY) As System.String Try 'Attempt the following block(s) of code... Return RoutineName 'Return the name of the referenced routine... Catch errRntm As System.Exception 'Trap any unexpected errors... RaiseError(False, m_MOD_CRNT, "GetRoutineName()", TextAids.TXT_EMPTY, errRntm.HResult, errRntm.Message, True, ResumeModes.RSM_PERSIST) 'Raise an error... Return TextAids.TXT_EMPTY 'Return an error value... End Try End Function
Ignore the call to the RaiseError() routine. That part I included as my error handler.