SPI Programming Manual (G06.24+, H06.03+, J06.03+)

SPI Concepts and Protocol
SPI Programming Manual427506-006
2-17
Buffer Pointers
token value. The next-token pointer is an internal buffer management position and
cannot be explicitly retrieved by an application.
The Last-Put-Token Pointer
The last-put-token pointer contains the position of the last token added to the buffer by
the SSPUT procedure, and is stored in the header token ZSPI-TKN-LASTPOSITION.
Its value can be retrieved by calling SSGET with ZSPI-TKN-LASTPOSITION. An
application can store this value and later return to the same location in the buffer by
using SSPUT to restore this value to the ZSPI-TKN-POSITION header token.
The Current-List Pointer
The current-list pointer always points to the currently selected list. If no list is selected,
this pointer is set to null.
Pointer Manipulation
Figure 2-4 on page 2-18 demonstrates how basic procedure calls affect the buffer
pointers. It shows a sequence of procedure calls and the resulting pointer movements:
1. The SSINIT call resets both the current-token and next-token pointers to the
beginning of the buffer, and the last-put-token pointer is null.
2. Four consecutive calls to SSPUT add four tokens to the buffer (Token T3 appears
twice.) After each call, the last-put-token pointer is updated.
3. When the buffer is reset, both the current-token and next-token pointers are reset
to the beginning of the buffer, and the last-put-token pointer is null.
4. The first SSGET call retrieves the value of token T1. The next-token pointer is set
to token T2. This is where the next SSGET starts searching the buffer the next
time it is called, unless a positive index is specified.
5. The next SSGET call uses the special operation ZSPI-TKN-NEXTTOKEN to
retrieve the token code of the next token in the buffer. Because only the token
codenot the token valueis retrieved, the next-token pointer remains at token
T2 with the current-token pointer. This allows the next call, which specifies the
token code just retrieved, to get the value for that token.
6. The third SSGET call retrieves the value for token T2, and the next-token pointer is
advanced.
7. The last SSGET call uses the index parameter to retrieve the value of the second
occurrence of token T3. The next-token pointer is now past all tokens in the buffer,
so another call to SSGET without any index parameter fails to find a token.
The procedure call series in Figure 2-4
is performed by the TAL program in
Example E-1
on page E-5 and the C program in Example E-2 on page E-7.