Bug in MSX-BASIC.

By NYYRIKKI

Enlighted (5918)

NYYRIKKI's picture

30-08-2003, 14:43

I have been wondering about this nasty feature, that bothers me every once in a while when I try to read binary files on MSX-BASIC.

Is it a known (or maybe even documented) feature, that when you check EOF and there is CHR$(0) character in a file you may loose a character?

I'm not really sure, but if I remember correctly this bug can be repeated on CAS: device as well. It is anyway more than 10 years, when I played with cassettes.

Below you can find an example of this bug. If you replace the CHR$(0) with any other value you get the correct value "6" now you will get "3" If you replace the character count with odd number, you get "Input past end" error, that should newer happen with this code.

10 OPEN "test.tmp" FOR OUTPUT AS #1
20 PRINT#1,STRING$(6,CHR$(0));
30 CLOSE
40 OPEN "test.tmp" FOR INPUT AS #1
50 R$=INPUT$(1,1):L=L+1
60 IF NOT EOF(1) THEN 50
70 CLOSE
80 PRINTL

Any ideas?

~NYYRIKKI

Login or register to post comments

By Arjan

Paladin (766)

Arjan's picture

07-09-2003, 13:54

It's probably an undocumented feature Smile I think INPUT$ was made to read textdata from a file, not binary data. It will also fail if you put the value 26 (EOF marker) in a file, so using INPUT$ is useless for reading binary data.

By anonymous

incognito ergo sum (116)

anonymous's picture

07-09-2003, 15:35

Good thinking! Smile