System Functions
PGM( ) Return Program Line
   
Formats PGM(lineno[,prog_level][,ERR=stmtref])
 
Where:

 

lineno Statement line number. Numeric expression.
  • If between integer from 1 and 64999 defines line number
  • -1, -2, or -3 returns program names instead.

See description below.

prog_level Optional numeric value indicating which program level to return.
stmtref Program line number or statement label to which to transfer control.

 

   
Returns String, compiled format of statement.
   
Description The PGM( ) function returns a string containing the internal (compiled) format of a given program statement number. If the line number is -1, the main (level 1) program name is returned; -2 returns the current program name and -3 returns the complete name of the program as specified on the CALL/LOAD/PERFORM or RUN.

If the statement number does not exist, and an ERR= option is specified, ProvideX returns Error #21: Statement number is invalid and transfers control to stmtref. If the statement number does not exist, and the ERR= option is omitted, ProvideX returns the next higher statement.

A typical occasion to use the prog_level would be to obtain lines from programs higher in the call stack such as X$ = LST(PGM(1, TCB(12) - 1)) which would return the first line of the calling program.

   
Examples The following examples illustrate different uses for the PGM( ) function.

Example 1:

1030 SWAPTST:
2:
2:A$=PGM(-1)
2:B$=PGM(-2)
2:PRINT A$," | ",B$
C:\OTHER\PGM\VX_MAINPR | C:\OTHER\PGM\PVX_SUBPR

Example 2:

0010 ! testpgm.-3
0020 CALL PGN+";label1;additional info"
0030 STOP
0040 LABEL1:
0050 PRINT "pgm(-3)='",PGM(-3),"'"
0060 EXIT
pgm(-3)='C:\PVX\estpgm.-3;label1;additional info'

Example 3:

0380 REM
0390 INPUT "Enter statement to display OR <F4> to Stop: ",A
0400 IF CTL<>4 THEN LET X$=PGM(A,ERR=0440) ELSE GOTO 0430
0410 PRINT LST(X$)
0420 GOTO 0390
0430 PRINT "DONE"; STOP
0440 PRINT "Error Transfer Works"; STOP
64999 PRINT "Cannot find statement"; END
-:run
Enter statement to display OR <F4> to Stop: 400
0400 IF CTL<>4 THEN LET X$=PGM(A,ERR=0440) ELSE GOTO 0430
Enter statement to display OR <F4> to Stop: 7000
64999 PRINT "Cannot find statement"; END
Enter statement to display OR <F4> to Stop: <F4> (not printable) DONE
-:run
Enter statement to display OR <F4> to Stop: 65999
Error Transfer Works