Re: [Ql-Users] loopy bug

2021-07-06 Thread pjwitte via Ql-Users

On 06/07/2021 14:13, Wolfgang Lenerz via Ql-Users wrote:

Hi Per,

an interesting pitfall, thanks for pointing that out.

It does seem that Qlib sets the value of the repeat loop control
variable to 0 at the start of the loop.

Do you know how this fares on plain QDOS, not SMSQE?

Regards

Wolfgang



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


I tested it under Qdos JS and both loops work exactly like in Qlib! 
Minerva, as one might have guessed, behaves like SBASIC. Clearly the 
smarter approach (why forbid something when it doesnt matter, and 
which might even come in handy?) but since its not consistent across 
the board, its best avoided.


Bob, Dilwyn: I only discovered this by chance, due to a spelling mistake.

Per
___
QL-Users Mailing List

Re: [Ql-Users] loopy bug

2021-07-06 Thread Wolfgang Lenerz via Ql-Users
Hi Per,

an interesting pitfall, thanks for pointing that out.

It does seem that Qlib sets the value of the repeat loop control
variable to 0 at the start of the loop.

Do you know how this fares on plain QDOS, not SMSQE?

Regards

Wolfgang


> 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
> 
> Per
> 
> ___
> QL-Users Mailing List
___
QL-Users Mailing List

Re: [Ql-Users] loopy bug

2021-07-06 Thread Dilwyn Jones via Ql-Users
I have encountered this before, but, like Bob said, assumed it was just a
question of a new type of variable being set up. In other words, I assumed
I was doing something wrong and simply avoided whatever was happening.

Dilwyn

On Tue, 6 Jul 2021, 11:55 Bob Spelten via Ql-Users, <
ql-users@lists.q-v-d.com> wrote:

> 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
___
QL-Users Mailing List


Re: [Ql-Users] loopy bug

2021-07-06 Thread Bob Spelten via Ql-Users

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

[Ql-Users] loopy bug

2021-07-06 Thread pjwitte via Ql-Users
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

Per

___
QL-Users Mailing List