MODNAME

Get the name of a routine

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
xcall MODNAME(choice, routine, [line][, file_number])

Arguments

choice

An expression that determines which routine’s name is returned: (n)

0 = Current routine

1 = Previous routine

2 = Routine before the previous routine

and so on…

routine

The variable that will be loaded with the name of the specified routine. (a)

line

(optional) The variable that will be loaded with the line number of the XCALL statement in the specified routine. (n)

file_number

(optional) The variable that will be loaded with the number of the .INCLUDEd source file that contains the XCALL statement in the specified routine. (n)

Discussion

The MODNAME subroutine returns the name of the current or a previous routine. If the name returned is that of the main routine, it is in the form “MAIN$name,” where name is the name of the main routine.

Routine is returned with blanks if you specify a nonexistent routine in choice. For example, if choice is 10 but the current call chain only has six routines, MODNAME returns blanks. With objects, the method signature is returned, and it can be quite large.

If choice is 0, line is the line number of the MODNAME statement. If choice is 1, line is the line number (in the previous routine) of the XCALL statement that called the current routine; and so forth.

When using the .INCLUDE compiler directive to include source code, use file_number in addition to line to uniquely identify the source file in which line exists. Because the file that contains the MODNAME routine is number 1, the first .INCLUDEd file is number 2, the second is number 3, and so forth. Each new file that is processed gets a new file number, even if it has been .INCLUDEd previously. (On .NET, file_number is always returned 0.)

Important

With Synergy .NET, line number information is accurate for Windows desktop and server applications only if the program is built in debug mode. And for x86 systems, if an application is built in debug mode, %ERROR returns the line number of the next executable line (if one exists) after the line for the requested routine. This is a Microsoft .NET Framework CLR limitation.

Important

With Synergy .NET, the file_number argument for MODNAME is always returned as 0.

Examples

The following subroutine provides the same type of traceback information that you’d get using the TRACE command in the debugger.

subroutine showtrace
.define TTCHN           ,1
record
    i                   ,d4
    modnam              ,a32
    blanks              ,a32
    line                ,d5
proc
    writes(TTCHN, "Calling chain is:")          ;TTCHN opened by calling routine
    xcall modname(i, modnam, line)              ;Start with current routine
    do
      begin
        writes(TTCHN, "in routine " + modnam)
        incr i
        xcall modname(i, modnam, line)
         if (modnam .ne. blanks)
           display(TTCHN, "at line " + %string(line))
      end
    until(modnam .eq. blanks)
    xreturn
endsubroutine