Shop OBEX P1 Docs P2 Docs Learn Events
SX/B - SubRoutine - Question on minimum # of parameters — Parallax Forums

SX/B - SubRoutine - Question on minimum # of parameters

John KauffmanJohn Kauffman Posts: 653
edited 2007-05-14 14:48 in General Discussion
(please delete same post with no subject line)

I am trying to understand the declaration and use of parameters in a section of code provided by Parallax in support of their serial display (part 27977).·The code works fine, I am not understanding how it works.
·
Question #1 regards a sub declaration’s MIN parameters
SX/B help states that in the sub declarations, the two arguments are the min and max number of parameters. If only one value is provded ten that is t emin and max. The code line of interest (follows, line 92) indicates that a minimum of two parameters must be sent when the sub is called.
LCD_STR······ SUB· 2············ ' send string to LCD
·
But when the sub is called in the program (follows, line 118) only one parameter is sent
LCD_STR " PARALLAX SX/B "

Question #2 – what does the parameter actually hold?
I lose the logic of the value in the parameter between the call of the sub and the use within the sub. When the sub is called the parameter is the string of characters to display. But within the sub the parameter seems to be an offset, which I would think is a number indicating where to start parsing the string to send individual bytes one at a time to the sub that actually displays them. And what value goes into temp4 since only one param was sent? I understand that the following code can pull characters from a data store (READ) but it is also used by the above GOSUB to display the literal string.
·
' Use: LCD_STR [noparse][[/noparse] string | label ]
' -- "string" is an embedded literal string
' -- "label" is DATA statement label for stored z-String
·
LCD_STR:·
temp3 = __PARAM1···· ' get string offset
temp4 = __PARAM2···· ' get string base
· DO
··· READ temp4 + temp3, temp5·· ' read a character
··· IF temp5 = 0 THEN EXIT····· ' if 0, string complete
··· LCD_OUT temp5·············· ' send the byte
··· INC temp3·················· ' point to next character
··· temp4 = temp4 + Z·········· ' update base on overflow
· LOOP
· RETURN

Comments

Sign In or Register to comment.