>>-QBUF--------------------------------------------------------><
queries the number of buffers that were created
on the data stack with the MAKEBUF command. The QBUF command returns
the number of buffers in the REXX special variable RC. If you have
not issued MAKEBUF to create any buffers on the data stack, QBUF sets
the special variable RC to 0. In this case, 0 is the number of the
buffer that is contained in every data stack.
You can use the
QBUF command in REXX execs that run in both the TSO/E address space
and non-TSO/E address spaces.
QBUF returns the current number
of data stack buffers created by an exec and by other routines (functions
and subroutines) the exec calls. You can issue QBUF from the calling
exec or from a called routine. For example, if an exec issues two
MAKEBUF commands and then calls a routine that issues another MAKEBUF
command, QBUF returns 3 in the REXX special variable RC.
The
following table shows how QBUF sets the REXX special variable RC.
Return code |
Meaning |
---|
0 |
Only buffer 0 exists on the data stack |
1 |
One additional buffer exists on the data stack |
2 |
Two additional buffers exist on the data stack |
n |
n additional buffers exist on the data
stack |
Examples
- If an exec creates two buffers on the data stack using the MAKEBUF
command, deletes one buffer using the DROPBUF command, and then issues
the QBUF command, RC is set to 1.
"MAKEBUF" /* buffer created */
⋮
"MAKEBUF" /* second buffer created */
⋮
"DROPBUF" /* second buffer created is deleted */
"QBUF"
SAY 'The number of buffers created is' RC /* RC = 1 */
- Suppose an exec uses MAKEBUF to create a buffer and then calls
a routine that also issues MAKEBUF. The called routine then calls
another routine that issues two MAKEBUF commands to create two buffers.
If either of the called routines or the original exec issues the
QBUF command, QBUF sets the REXX special variable RC to 4.
"DROPBUF 0" /* delete any buffers MAKEBUF created */
"MAKEBUF" /* create one buffer */
SAY 'Buffers created = ' RC /* RC = 1 */
CALL sub1
"QBUF"
SAY 'Buffers created = ' RC /* RC = 4 */
EXIT
sub1:
"MAKEBUF" /* create second buffer */
SAY 'Buffers created = ' RC /* RC = 2 */
CALL sub2
"QBUF"
SAY 'Buffers created = ' RC /* RC = 4 */
RETURN
sub2:
"MAKEBUF" /* create third buffer */
SAY 'Buffers created = ' RC /* RC = 3 */
⋮
"MAKEBUF" /* create fourth buffer */
SAY 'Buffers created = ' RC /* RC = 4 */
RETURN