Make your own free website on Tripod.com
7.2.3 Using multiple buffers in the stack
The concept of buffers and everything directly related to buffers
lay without the domain of standard REXX. Thus, this section
describes a de facto standard.

Some implementations support “buffers”, which are a means of
focusing on a part of the stack. When creating a new buffer, the
old contents of the stack is somewhat insulated from the effects
of stack operations. When the buffer is removed, the state of the
old buffer i restored, to some extent: Whenever a string is read
from the stack, and the topmost buffer on the stack is empty, then
that buffer will be destroyed. Consequently, if this situation has
arisen, dropping buffers will not restore the state of the stack
before the buffer was created.

The functionality of buffers, and their effect on other stack
operations may differ considerably between implementations.

Whenever a queuing operations is performed (e.g. by the QUEUE
instruction), then the new string is inserted into the bottom of
the topmost buffer, not the bottom of the stack. This is the same
if the stack has no buffers, but else, the outcome of the queuing
operation can be very different.

With IBM mainframe operating systems like CMS, buffers can be
inserted on the top of the stack. To perform buffer operations,
operating system commands are used. It may be instructional to
list the buffer operations of CMS:

[DESBUF]
     Removes all strings and buffers from the stack, and leaves
     the stack clean and empty. It is often used instead of
     repeated calls to DROPBUF. It always returns the value zero.

[DROPBUF]
     Removes zero or more buffers from the stack. It takes one
     parameter which can be omitted, and which must be an integer
     position if specified, and is the assigned number of the
     bottom-most buffer to be removed, i.e. that buffer and all
     buffers above it (and of course, all the strings in these
     buffers) are to be removed. If the parameter is not
     specified, only the topmost buffer is removed.  The return
     valued is always zero, unless an error occurred.

[MAKEBUF]
     Makes a new buffer on the stack, starting at the current top
     of the stack. The return code (as stored in the special
     variable RC) is the number of buffers currently on the stack
     after the new buffer has been added.  Obviously, this will be
     a positive integer.  This program takes no parameters.

One might regard a buffer as a sort of bookmark, which is inserted
into the stack, so that a subsequent DROPBUF command can remove
the stack down to a particular such bookmark.

When such a mark is located on the top of the stack, and a PULL
instruction is executed, the buffer mark is implicitly destroyed
when the PULL instruction reads the string below the buffer mark.
This is to say that a buffer can be destroyed by either a DESBUF
command, a DROPBUF command, or a read from the stack (by either
the PULL or PARSE PULL instructions).



PREV NEXT