[Coco] Release CenterText.b09

James Jones jejones3141 at gmail.com
Mon Apr 9 16:08:48 EDT 2018


Wayne Campbell is quite right about making those numeric variables integer,
but few to none of them are actually necessary. Ditto for most of the
string variables. T3 is set and never used; T2 is set to the empty string
and then overwritten; it might as well just be set rather than appended to,
and one could just as well PRINT T1;TT, but all that said, since one has
PRINT USING which can center strings, why not take advantage of it?

Actually, there may be one reason; if you fill it out to the screen width,
it may do something unfortunate like gratuitously double space or even
scroll on the bottom line. The code as written doesn't print out the
trailing spaces--I take it something else has always cleared the line?--and
perhaps that's why, in which case one could write what does the same but
doesn't clearly say "yes, I am centering this":

PROCEDURE CenterText
    PARAM width:INTEGER;text:STRING[80]
    PRINT USING "S"+STR$(INT((width-LEN(text))/2)),"";
    PRINT text

The following is by far preferable if it doesn't cause unfortunate
wrapping--actually, that's why I added the semicolon in the original reply:

PROCEDURE CenterText
    PARAM width:INTEGER;text:STRING[80]
    PRINT USING "S"+STR$(width)+"^", text

Now, so far we've ignored the POKE. What's special about the byte at
address 64301? What owns it? Can one have two processes running the budget
program concurrently?


More information about the Coco mailing list