The following warnings occurred:
Warning [2] Undefined array key 0 - Line: 1677 - File: showthread.php PHP 8.2.31 (Linux)
File Line Function
/inc/class_error.php 157 errorHandler->error
/showthread.php 1677 errorHandler->error_callback
/showthread.php 916 buildtree




Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
for-next repeats forever because of data type limit
#5
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.
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)