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

SPI Concepts and Protocol
SPI Programming Manual427506-006
2-23
Pointers, Lists, and ZSPI-TKN-NEXTTOKEN
Pointers, Lists, and ZSPI-TKN-NEXTTOKEN
Figure 2-6 on page 2-24 shows the behavior of SSGET special operation ZSPI-TKN-
NEXTTOKEN when working in and around lists. It demonstrates a sequence of
procedure calls and the resulting pointer changes. Although the figure shows a data
list, the demonstrated behavior applies to all list types:
1. The data portion of the buffer contains seven tokens (T1, T2, two occurrences of
T3, T4, ZSPI-TKN-DATALIST, and ZSPI-TKN-ENDLIST) with tokens T2 and T3
inside the data list. The SSPUT special operation ZSPI-TKN-RESET-BUFFER
resets both the current-token and next-token pointers to the beginning of the
buffer. The current-list pointer remains null until a list is selected.
2. The first SSGET call asks for the next token in the buffer, and retrieves token T1.
3. The next SSGET asks for the next token in the buffer, and retrieves the list token
ZSPI-TKN-DATALIST. The current-token and next-token pointers are set to this
token and, because the list token was selected, the current-list pointer is defined.
4. The next SSGET call retrieves the next token, now from within the list.
5. Because SSGET is working within the list, an attempt to retrieve a token outside
the list fails with error ZSPI-ERR-MISTKN, and the pointers are unchanged.
6. An SSGET call uses the index parameter to retrieve the second occurrence of
token T3 from within the list.
7. The next token in the buffer is ZSPI-TKN-ENDLIST, and by selecting it SSGET
exits the list.
8. Outside the list now, SSGET can retrieve token T4.
9. Token T4 is the last token in the buffer, so a call to SSGET asking for the next
token returns error ZSPI-ERR-MISTKN.
The procedure call series in Figure 2-6
is performed by the TAL program in
Example E-5
on page E-15 and the C program in Example E-6 on page E-19.