Forum
Spectrum keywords codes - Printable Version

+- Forum (https://www.boriel.com/forum)
+-- Forum: Compilers and Computer Languages (https://www.boriel.com/forum/forumdisplay.php?fid=12)
+--- Forum: ZX Basic Compiler (https://www.boriel.com/forum/forumdisplay.php?fid=11)
+---- Forum: Bug Reports (https://www.boriel.com/forum/forumdisplay.php?fid=15)
+---- Thread: Spectrum keywords codes (/showthread.php?tid=2618)



Spectrum keywords codes - Zoran - 03-07-2025

Hello,

The documentation for CHR function (https://zxbasic.readthedocs.io/en/latest/chr/) says that, although expanded, the function is 100% Sinclair basic compatible.
If it is so, then for the same parameters I'd expect the same output, not only for ascii letters, but also for sinclair basic keywords.

In Sinclair basic, this programme:

Code:
10 CLS
20 FOR i = 230 TO 250
30 PRINT CHR$ i
40 NEXT i

gives some Basic keywords in the output (see the attached image zxkeywords_sinclair.png).

.png   zxkeywords_sinclair.png (Size: 10.26 KB / Downloads: 99)

The equivalent programme in ZX Basic:
Code:
dim i as ubyte

cls
for i = 230 to 250
    print chr(i)
next

outputs some silly characters (see the attached image zxkeywords_boriel.png).

.png   zxkeywords_boriel.png (Size: 11.44 KB / Downloads: 78)

Compiled with:
Quote:..\..\zxbasic\zxbc.exe --optimize 2 --output zxkeywords.tzx --output-format tzx --BASIC --autorun --explicit --strict zxkeywords.bas

I'd say it is a bug.


RE: Spectrum keywords codes - boriel - 03-08-2025

This is because PRINT is not using the ROM.
PRINT is totally implemented from scratch, so BASIC tokens are not output.
Only graphic chars and UDG, along with the normal charset supported.