Those of you on ql-user's will, unfortunately, have seen this one quite recently:
I dont know if this has been documented anywhere, but Im putting it out here as it caused me some grief.
It appears that Q-Liberator zeroes the loop variable on entry to a loop. The following demo, which is acceptable (although perhaps not very elegant) S*BASIC, will not work in the same way in SuperBASIC or when Qlib compiled.
Code: Select all
100 loop = 3
110 cnt = 0
120 PRINT 'Start:'! loop, cnt
130 REPeat loop
140 PRINT loop, cnt
150 cnt = cnt + 1
160 IF cnt >= loop: EXIT loop
170 END REPeat loop
180 PRINT 'End:'! loop, cnt
The worrying part of this is that while I was figuring out what was wrong, running an embedded routine like this many times, the system crashed due to memory corruption. Whether this was due to the SBASIC or Qlib compiled version (or neither) I cant say. So just beware and keep on progging!
NB: This works across the board, though, as long as you expect loop to be 0
Code: Select all
110 cnt = 3
120 PRINT 'Start:'! loop, cnt
130 REPeat loop
140 PRINT loop, cnt
150 loop = loop + 1
160 IF loop >= cnt: EXIT loop
170 END REPeat loop
180 PRINT 'End:'! loop, cnt