Input/Output Buffers

Proc uses four input/output buffers:

Proc moves data from the active input buffer to either output buffer, forming the desired TCL and processor commands.

The primary input buffer is the active input buffer most of the time. The secondary input buffer is used by very few Proc commands.

Primary Input Buffer

The primary input buffer initially contains the Proc name and any optional arguments, exactly as they were entered when the Proc was invoked.

In PQN Procs, primary input buffer parameters are referenced with a percent sign (%), and any parameter can be displayed by using the T command.

This buffer is a work area, typically used for terminal input and for storing parameters that control the sequence of Proc execution.

Proc does not provide variable assignment as DataBasic does. However, you can achieve the same result by using parameters of the primary input buffer as storage locations.

When the Proc is executed from DataBasic via a CHAIN or PERFORM statement, the primary input buffer is initialized to contain the value of the CHAIN or PERFORM expression.

A DataBasic program that is run from a Proc (in which control will return to the Proc when the DataBasic program is finished) can alter the contents of the primary input buffer with the PROCWRITE statement.

Secondary Input Buffer

The secondary input buffer contains data input by the user in response to an IN command. Also, TCL commands and English commands that return an error code write this code to the secondary input buffer. The IF E command tests this returned error code. Spooler hold file numbers are also returned to the SIB in the form HFNn, where n is the hold file number. The data in this buffer is volatile and is overwritten by subsequent IN commands and by returned error codes.

The MS command copies the entire contents of the secondary input buffer to the primary input buffer, provided that the primary input buffer is active.

Active Input Buffer

The primary input buffer is initially active when a Proc is executed from TCL or at logon.

It remains active until an IN or IBN command is executed, when the secondary input buffer becomes active.

The secondary input buffer then remains active until an RI, S (n) or MV %n source command is executed.

Many commands access the active input buffer. These include the A and Ap forms of the A command, B, D (without parameter), F, IBH, IH, IP and Sp.

Therefore, you should be careful when using the IN or IBN command as, by selecting the secondary input buffer, they may affect the data accessed by subsequent commands. It is recommended that you avoid these complications.

Primary Output Buffer

The primary output buffer holds the command which is submitted at the TCL level for processing via the P command. Any command (except LOGTO) which can be executed at TCL can be constructed and executed via a Proc.

Note

Use a Proc transfer when invoking one Proc from another. Never place the Proc name in the output buffer in order to execute it.

The active output buffer is referenced via a hash sign (#) in PQN Procs.

Upon exiting a Proc, a command left in the primary output buffer is automatically executed.

Secondary Output Buffer

The secondary output buffer contains data used to feed interactive processes, such as DataBasic, TCL, or the EDITOR, when they request input.

The active output buffer is referenced via a hash sign (#) in PQN Procs. The secondary output buffer is made active via the STON (stack on) command.

Data can be placed in the secondary output buffer before running a DataBasic program. The data is then available to satisfy INPUT requests in the DataBasic program, just as if it were placed in the data stack by a DATA statement.

The secondary output buffer is often referred to as the "stack." In fact, it is the same buffer as that used by the DATA statement in DataBasic.

If the Proc is executed from TCL, the secondary output buffer is initialized to empty at the start of the Proc.

If the Proc is executed from a DataBasic program via a CHAIN or PERFORM statement, the secondary output buffer is not initialized. Therefore, any data placed in the data stack by a DATA statement will be present in the secondary output buffer. However, this is not a desirable method of passing data from a DataBasic program to a Proc because the Proc input statements ignore stacked data.

Data in the secondary output buffer is available to be copied.

Active Output Buffer

The secondary output buffer becomes the active output buffer when the STON (Stack On) command is executed.

The primary output buffer is the active output buffer at Proc start-up and after a STOFF (Stack Off) command is executed.

Some operations, such as COPY and EDIT, require two buffers so it can be necessary to switch between output buffers when loading them.

Parameters and Pointers

Data in the input/output buffers is contained in the form of a series of parameters separated by blanks (PQ) or attribute marks (PQN).

References to a parameter in one of the buffers are made using the sequential number of that parameter within the buffer. For example, you can refer to the 6th parameter in the primary output buffer or to the data starting in column 16 of the primary input buffer. Parameters are numbered starting at 1.

 There are three buffer pointers:

In the examples throughout this section, buffer pointers are indicated by an up arrow (↑).

Attribute marks - parameter separators in PQN Proc - are indicated by a caret (^).

The input buffer pointer points to the active input buffer. This pointer can be moved back and forth without affecting the data in the buffer.

The S, F and B commands all affect the input buffer pointer. The S command positions the input buffer pointer, while the F and B commands move the pointer forward or backward, respectively.

Each output buffer has its own pointer, which always points to the end of the data. If the pointer is moved backward, the data at the end of the buffer is truncated.

The BO command is used to move the primary output buffer pointer back one parameter and erase the last parameter or to clear the secondary output buffer.

Notes on Output Buffers

Each line of data placed in the secondary output buffer using the H command must be terminated by typing a less-than character (<) that represents a carriage return.

The P command is used to execute commands stored in the primary output buffer.

A carriage return is automatically placed at the end of the TCL command in the primary output buffer upon execution of that buffer via the P command.

Because data is moved into the secondary output buffer in blocks of 140 characters or less, it is necessary to separate each line of data with two less-than characters (<<) that represent a stack continuation character every 140 characters or less.