SPI Programming Manual (G06.24+, H06.03+, J06.03+)
General SPI Programming Guidelines
SPI Programming Manual—427506-006
5-2
Scanning a Buffer Sequentially
After the call, the positioning is:
current next
| |
v v
<TKN-A> <TKN-B> <TKN-C> <TKN-A> <TKN-D>
The SSGET procedure also includes a count parameter. This feature lets a program
extract up to the specified number of occurrences of a token in one call, whether they
are contiguous or not, and receive their values as an array.
Scanning a Buffer Sequentially
A program can scan the buffer sequentially and retrieve each token in order using one
of the special SSGET operations ZSPI-TKN-NEXTCODE and ZSPI-TKN-
NEXTTOKEN. This method of token retrieval is useful mainly to servers because they
must examine every token in the buffer and reject messages that contain unrecognized
or invalid tokens.
A call to SSGET with ZSPI-TKN-NEXTTOKEN gets the next token code in the buffer,
regardless of whether that token has the same token code as the current token, and
regardless of whether that token is within a list.
For example:
CALL SSGETTKN (buffer, ZSPI-TKN-NEXTTOKEN, value)
Before the call, the positioning is:
current next
| |
v v
<TKN-A> <TKN-B> <TKN-C> <TKN-A> <TKN-D>
After the call, the positioning is:
current + next
|
v
<TKN-A> <TKN-B> <TKN-C> <TKN-A> <TKN-D>
A call to SSGET with ZSPI-TKN-NEXTCODE gets the next token different from the
token code at the current position. Unlike ZSPI-TKN-NEXTTOKEN, this operation does
not see tokens within lists until the beginning list token is selected, and it skips over
any tokens that have the same token code as the current token.
Repeated calls using the ZSPI-TKN-NEXTCODE operation return non-contiguous
occurrences of the same token code in the same order as they were supplied by
SSPUT. The result gives the number of contiguous occurrences,
not
the total number
of occurrences in the buffer. For example, suppose the buffer contains:
<TKN A> <TKN A> <TKN A> <TKN B> <TKN A> <TKN A> <TKN C>