Returns the file name of the program being executed. You can use SYS(16) to recover from errors.
SYS(16 [, 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. For more information about program nesting levels, see maximum number of DO calls in Visual FoxPro System Capacities. 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.
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.
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