SPI Programming Manual (G06.24+, H06.03+, J06.03+)
SPI Concepts and Protocol
SPI Programming Manual—427506-006
2-25
Pointers, Lists, and ZSPI-TKN-NEXTCODE
Pointers, Lists, and ZSPI-TKN-NEXTCODE
Figure 2-7 on page 2-26 shows the behavior of SSGET special operation ZSPI-TKN-
NEXTCODE in the same buffer scanned with ZSPI-TKN-NEXTTOKEN in Figure 2-6
on
page 2-24. It demonstrates a sequence of procedure calls and the resulting pointer
movements. 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 code in the buffer, and retrieves token
code T1.
3. The next SSGET call asks for the next different token code in the buffer, and
retrieves the list token ZSPI-TKN-DATALIST. However, unlike ZSPI-TKN-
NEXTTOKEN, the NEXTCODE special operation does not select the list.
4. Because the list was not selected, the next SSGET call ignores the contents of the
list and retrieves token T4, the next different token at the top level.
5. SSGET is called to select the list token and enter the list. An index parameter of 1
is specified to ensure that SSGET scans from the beginning of the buffer.
6. Now within the list, SSGET NEXTCODE retrieves the next different token code T2.
7. The same call repeated retrieves token T3.
8. The next call retrieves ZSPI-TKN-ENDLIST.
9. Because SSGET is still in the list, it cannot retrieve token T4, which is outside the
list. SSGET returns error ZSPI-ERR-MISTKN, and the pointers are unchanged.
The procedure call series in Figure 2-7
is performed by the TAL program in
Example E-7
on page E-22 and the C program in Example E-8 on page E-25.