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

General SPI Programming Guidelines
SPI Programming Manual427506-006
5-33
Checking Tokens in the Command
go to send^reply
end
! For simple, variable-length tokens, a check of
! the length is needed. Omit this for fixed-
! length tokens. (Omitting the token code that
! is the third argument to SSGET means to use
! the token at the current position.)
SSGET(buf,ZSPI^TKN^LEN,,,byte^len)
if byte^len > size of token1^value then
begin
reject(token,count[subsys^TNM^TOKEN1],
subsys^ERR^VALUE^TOO^LONG)
go to send^reply
end
SSGET(buf,subsys^TKN^TOKEN1,
token1^value[count[subsys^TNM^TOKEN1]-1])
if SSGET error then
begin
ssgeterr(subsys^TKN^TOKEN1,0,SSGET status)
go to send^reply
end
subsys^TNM^TOKEN2 -> ! extensible structured token
if token.z^tkntype <> ZSPI^TYP^STRUCT then
begin
reject(token,1,subsys^ERR^IMPROPER^TOKEN)
go to send^reply
end
count[subsys^TNM^TOKEN2] :=
count[subsys^TNM^TOKEN2] + 1
if count[subsys^TNM^TOKEN2] > limit^for^token2
then
begin
reject(token,count[subsys^TNM^TOKEN2],
subsys^ERR^TOO^MANY^OCCURENCES)
go to send^reply
end
SSGET(buf,subsys^MAP^TOKEN2^V,
token2^value[count[subsys^TNM^TOKEN2]-1])
if SSGET error then
begin
ssgeterr(subsys^MAP^TOKEN2^V,0,SSGET status)
go to send^reply
end
(Repeat for each token allowed in this command.)
otherwise ->
reject(token,1,subsys^ERR^IMPROPER^TOKEN)