PGM() Function - BBj


For this topic's original documentation, see the PGM() Function - Get Program Text.

BBj-Specific Information

Syntax

PGM(int[,int])

In the above syntax, second int indicates a program level in the range 0 through TCB(13).

In BBx, the CPL(), LST() and PGM() functions expose the internal structure of the compiled program. BBj implements these functions in a way that does not expose internal implementation details.

In BBj, the PGM() function returns the listed version of a specified line from the current workspace program. In BBx, the PGM() function returns the internal compiled form.

Parameter

Description

int

PGM(-1) unchanged from BBx

PGM (-2) unchanged from BBx

PGM (65536) has no special meaning in BBj

Additional notes:

  • PGM(linenum,level) returns the listed version of a specified line from the program at the specified level, where level is in the range 0 through TCB(13).

  • PGM(linenum,0) is equivalent to PGM(linenum) and returns linenum from the workspace program.

  • PGM(-1,level) or PGM(-2,level) returns the name of the program at the specified level. PGM(-1,0) returns the name of the workspace program. PGM(-1,TCB(13)) returns the name of the current program.

  • PGM(linenum,TCB(13)) returns linenum from the current program.

Example

0010 REM ' Hello
0020 PRINT "Hello, world"
0030 END
?pgm(1)
0010 REM ' Hello
?pgm(10)
0010 REM ' Hello
?pgm(30)
0030 END
?pgm(99)
***** END

Example 2

>run "main.bbx"
0010 REM ' main
0020 CALL "call.bbx"
>ENTERING: call.bbx
0010 REM ' call
0020 SETOPTS $08$
0030 ESCAPE
0030 ESCAPE

READY
[1]call.bbx>?pgm(-1,tcb(13))
call.bbx
[1]call.bbx>?pgm(-1,0)
main.bbx
[1]call.bbx>?pgm(10,0)
0010 REM ' main
[1]call.bbx>?pgm(10,tcb(13))
0010 REM ' call
[1]call.bbx>