Share via


SYS(16) - Executing Program File Name

Returns the file name of the program being executed. You can use SYS(16) to recover from errors.

SYS(16 [, nProgramLevel])

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.

Return Values

Character

Remarks

SYS(16) is similar to PROGRAM( ) except that SYS(16) returns a path with the program name. When the executing program is part of an application (.app), SYS(16) returns only the name of the program, that is, without the path. SYS(16) returns the name of the executable file if called from an executable (.exe) file; 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.

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