pjwitte via Ql-Users wrote:
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 once compiled with Qlib.
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
190 PAUSE: QUIT
In the Qlib-compiled version the loop is exited after a single run as
the condition cnt >= loop is met immediately, to wit 1 >= 0
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 I cant say right now. So just beware and keep on
progging!
NB: This works, though. As long as you start out with loop = 0
100 loop = 0
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
190 PAUSE: QUIT
Not that I have ever had this problem but when using a REPeat variable
as a value I've always made sure it was only used within the Loop.
In the Name Table a simple variable is marked differently ($0202) from a
REPeat index ($0602), the question is who is doing it right?
When Qlib encounters the 2nd 'loop' it probably sets up a new zero entry
with the same name.
In your second example the first 'loop = 0' is most likely not relevant.
Bob
--
Deze e-mail is gecontroleerd op virussen door AVG.
http://www.avg.com
_______________________________________________
QL-Users Mailing List