2 buffer data type – Compaq DEC Text Processing Utility AA-PWCBD-TE User Manual
Page 43
DEC Text Processing Utility Data Types
3.1 Array Data Type
int_array := CREATE_ARRAY (10, 1);
int_array {1} := "Store a string in the first element";
int_array {8} := CURRENT_BUFFER;
int_array {42} := "This is a dynamically created element.";
If you assign a value to an element that has not yet been created, then that
element is dynamically created and both the index and the value are stored.
Subsequent references to that element index return the stored value.
In most cases, if you reference an element that has not yet been created and
you do not assign a value to the nonexistent element, DECTPU does not create
the element. DECTPU simply returns the data type unspecified. However, if
you reference a nonexistent element by passing the nonexistent element to a
procedure, DECTPU adds a new element to the array, giving the element the
index you pass to the procedure. DECTPU assigns to this new element the data
type unspecified.
You can delete an element in the array by assigning the data type unspecified to
the element. For example, the following statement deletes the element my_array
{
"
fred
"
}:
my_array {"fred"} := TPU$K_UNSPECIFIED;
The following code fragment shows how you can find all the indexes in an array:
the_index := GET_INFO (the_array, "FIRST");
LOOP
EXITIF the_index = TPU$K_UNSPECIFIED;
.
.
.
the_index := GET_INFO (the_array, "NEXT");
ENDLOOP;
Note
DECTPU does not guarantee the order in which it will return the array
indexes.
3.2 Buffer Data Type
A buffer is a work space for manipulating text. A buffer can be empty or it
can contain text records. You can have multiple buffers. A value of the buffer
data type is returned by the CREATE_BUFFER, CURRENT_BUFFER, and
GET_INFO built-in procedures. CREATE_BUFFER is the only built-in procedure
that creates a new buffer. CURRENT_BUFFER and GET_INFO return pointers
to existing buffers.
The following statement makes the variable my_buf a variable of type buffer:
my_buf := CREATE_BUFFER ("my_buffer");
When you use a buffer as a parameter for DECTPU built-in procedures, you must
use as the parameter the variable to which you assigned the buffer. For example,
if you want to erase the contents of the buffer created in the preceding statement,
enter the following:
ERASE (my_buf);
DEC Text Processing Utility Data Types 3–3