Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Breaking loops
#6
baltasarq Wrote:What I'm trying to tell you is that "break" is compiled without warning or error. You can even run the program, and then, "break" is not executed as "exit loop" or whatever... it' actually as it was a nop.

Try this:

Code:
dim m(10) as byte => { 11, 22, 33, 44, 55, 66, 77, 88, 99, 100, 110 }

for i = 0 to 10
    if m( i ) = 66
        break
    end if
next

print "i = "; i

Compile it with this:

Code:
python ~/bin/zxbasic/zxbc.py -f tap --BASIC --autorun --debug-array sample.bas

And then it compiles okay (not even warnings), then you run it in the emulator, and the output is 11.

Code:
i = 11

Oh, then this is obiously a bug.
I'll review the code. As you said it should either EXIT the current (inner) loop or throw syntax error.
---
Boriel
Reply


Messages In This Thread
Breaking loops - by baltasarq - 02-07-2025, 12:28 PM
RE: Breaking loops - by boriel - 02-08-2025, 06:50 PM
RE: Breaking loops - by baltasarq - 02-08-2025, 07:48 PM
RE: Breaking loops - by boriel - 02-09-2025, 04:34 PM
RE: Breaking loops - by baltasarq - 02-10-2025, 09:23 AM
RE: Breaking loops - by boriel - 02-10-2025, 09:58 AM
RE: Breaking loops - by boriel - 02-16-2025, 05:07 PM
RE: Breaking loops - by baltasarq - 02-16-2025, 06:51 PM
RE: Breaking loops - by boriel - 02-16-2025, 09:29 PM
RE: Breaking loops - by boriel - 02-16-2025, 10:26 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)