04-11-2010, 02:36 PM
boriel Wrote:Quote:I'll check what FreeBASIC does in such cases.Please, do, since I'm trying to get close to FreeBasic as much as possible (preserving most of ZX BASIC on the other side ;-))
I modified the code to check it with FreeBASIC, and it works exactly the same way: the 0-255 loop repeats forever when the index variable is ubyte:
Code:
' FreeBASIC
' The following loop works as expected:
cls
print "Press q to quit"
dim b0 as ubyte
for b0=0 TO 254
locate 2
print "b0=";b0;" "
next b0
' The following loop works as expected too:
dim b1 as uinteger
for b1=0 TO 255
locate 3
print "b1=";b1;" "
next b1
' But the following loop starts again forever:
dim b2 as ubyte
for b2=0 TO 255
locate 4
print "b2=";b2;" "
if inkey="q" then end endif
next b2
print "This message never will be printed"
sleep
By the way, the compatibility with FreeBASIC would be great: for certain programs, one source code could be compiled both for the ZX Spectrum and for other platforms --to some extent, with some conditional compilation. I'm starting working on some projects with FreeBASIC and ZX Basic, so I'll have the chance to explore the issue.
Marcos Cruz
http://programandala.net
http://programandala.net