XC-BASIC
XC-BASIC copied to clipboard
Print formatted numbers
This request emerged in the discussion on issue #52.
It's about a command to be added that prints integers as unsigned numbers. It would also be nice to print hex or binary numbers. I don't think I'll have time for some very sophisticated thing like sprintf
or PRINT USING
, something simplier should do the job.
Ideas:
- a new I/O command, e. g.
FPRINT number, "format"
or - a new string command, e. g.
STR number, string$, "format"
(because it would be similar to CBM BASIC'sSTR$()
function that converts a number to string)
The difference is that the former prints directly while the latter only does the conversion and copies it into a string that can be subsequently PRINT
ed or TEXTAT
ed.
I think this should really be promoted as high priority. String manipulation is one of the strengths of a BASIC language over other languages. I'm currently struggling on how to convert numbers into string representations and combine them to build commands to send to the 1541. Tough to do when I can't simply do device$ + " " + track$ + " " + sector$
.. 🤕