Share via


SYS(16) - Executing Program File Name

Returns the file name of the program being executed.

SYS(16 [, nProgramLevel])

Return Values

Character

Parameters

  • nProgramLevel
    Indicates from how many levels back the program name is fetched. This value can range from 1 to the depth at which programs are nested.

    If nProgramLevel is 0 or 1, SYS(16) returns the name of the main program (the program first executed). The name of the currently executing program is returned if nProgramLevel is omitted. The empty string is returned if nProgramLevel is greater than the program nesting depth.

Remarks

This option is useful for recovering from errors. SYS(16) is similar to PROGRAM( ). However, SYS(16) returns a path with the program name; whereas PROGRAM( ) returns just the program name.

If a procedure or function is being executed, SYS(16) returns the name of the file containing the procedure or function after the procedure or function name.

When the executing program is part of an application (.app), SYS(16) returns only the name of the program — the path isn't returned with the program name.

Example

The program nesting is returned in the following short program example:

STORE 1 TO gnX
DO WHILE LEN(SYS(16,gnX)) != 0
   ? SYS(16,gnX)
   STORE gnX+1 TO gnX
ENDDO

See Also

LINENO( ) | ON ERROR | PROGRAM( ) | SYS( ) Functions Overview