Download Process-Pascal Version 4 Users Manual - Proces-Data

Transcript
502 052 02
15 Buffer
A buffer is considered as a FIFO (First In First Out), where elements are placed in
the end of a queue when a variable is assigned to the buffer, and the elements are
removed from the front of the queue, when the buffer is assigned to a variable.
When operating with buffers, the inserting and removing of elements, considers the
entire element. This means that if the element type is a structured type, you can not
access a specific field directly in the buffer. Instead you must assign the whole
element to a variable of the same type and then access the particular field in that
variable.
Buffers have a fixed number of elements of one type, the element type. The element
type can be of any type except a BUFFER type and a TIMER type.
The syntax for a buffer type is:
The constant denotes the buffer size, the max. number of elements in the buffer.
When an element is read out from a buffer, it is deleted from the buffer and cannot
be read out again.
Buffers must always be initiated before they are used the first time. This is done with
the standard procedure InitBuffer(buffername).
Before a variable is assigned to a buffer, the program must check if the buffer is full.
This is done with BufferFull(buffername) which is a standard function. The function
returns a boolean, TRUE if the buffer is full. If a variable is assigned to a buffer and
the buffer is already full, an error is produced and the value will not be stored into
the buffer, until an element has been removed from the buffer.
Before a buffer is assigned to a variable, the program must check if the buffer is
empty. This is done with BufferEmpty(buffername) which is also a standard function.
The function returns a boolean, TRUE if the buffer is empty. If an empty buffer is
assigned to a variable, an error is produced and the variable will not be assigned
until an element has been inserted in the buffer.
If a variable of the type BUFFER is a component of a complex variable, the buffer
component variable is only to be used internally in the controller.
(P-NET restriction).
Manual
Process-Pascal 4.0
37/141