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

SPI Programming Examples
SPI Programming Manual427506-006
E-72
Example E-15: Common Routines for TAL Examples
IF p^tkn^code = zspi^tkn^server^version THEN
sp ':=' "(SERVER^VERSION)" -> @sp;
IF p^tkn^code = zspi^tkn^ssid THEN
sp ':=' "(SSID)" -> @sp;
END;
?PAGE "PROC dump^buf"
PROC dump^buf (p^spi^buf);
!==========================================================================!
! Proc : dump^buf !
! Function : This procedure will perform a labeled dump of the passed SPI !
! buffer and display it on the home term. !
!==========================================================================!
INT .p^spi^buf;
BEGIN
LITERAL numeric^format = 10, ! Decimal
string^format = 0, ! Char codes 32 - 126
type^override = 0, ! No TYPE overrides
show^redef = 0, ! Don’t show redefines
show^hidden = 1, ! Show hidden fields
no^header = 0, ! Show header and data fields
name^or^label = 1, ! Use DDL names
ems^or^ss = 1,
tkn^label^len = 30,
field^label^len = 0,
max^lines = 10,
max^line^len = 80;
! Note that the SPI_formatnext procedure can modify the spi buffer.
! Thus I will move it to l^spi^buf and display it from here.
INT .l^spi^buf [0:max^bufsize]; ! buffer to display
INT .l^format^buf [0:max^lines * max^line^len / 2];
STRING .l^sformat^buf := @l^format^buf '<<' 1;
INT .l^lengths [0:max^lines];
INT l^buf^len,
l^idx,
l^cmd^num,
l^done := 0,
l^format^id, !used by formatting routines to keep track of info.
l^status,
l^status1,
l^status2;
l^spi^buf ':=' p^spi^buf FOR $OCCURS (l^spi^buf) WORDS;
! get a format area reserved
err := spi_buffer_formatstart_ (l^format^id, numeric^format, string^format,
type^override, show^redef, show^hidden,
no^header, name^or^label, ems^or^ss,
tkn^label^len, field^label^len,
l^status1, l^status2);
IF err THEN
CALL display^spi^error (err, zspi^val^buffer^formatstart, 0d, true);
err := 0;
WHILE NOT l^done DO
BEGIN
err := spi_buffer_formatnext_ (l^format^id,
l^spi^buf,
l^sformat^buf: max^lines*max^line^len,
max^lines,
l^lengths,
l^status1,
l^status2);
Example E-15. TAL File: SETCUTIL Supporting Code (page4of5)