Two loops not working in 1.47.2 but ok in 1.44.2

Here we can discuss about the problem found
Post Reply
bugs
Posts: 142
Joined: Mon Feb 08, 2021 10:10 pm
Location: Scotland
Has thanked: 44 times
Been thanked: 50 times

Two loops not working in 1.47.2 but ok in 1.44.2

Post by bugs »

Probably been mentioned already but I could not find it with search.
Getting "Return without gosub at line 18" at end of loop in subroutine.
Single stepping shows the loop command at line 7 is jumping directly to loop2 at line 14

Code: [Local Link Removed for Guests]

' do - loop test
x=0
do until x=3
  wlog "loop1 #";x
  gosub loop2
  x=x+1
loop
wlog "Terminated ok"
end

loop2:
  wlog "loop2 #";x
  y=0
  do until y=2
    wlog y
    y=y+1
  loop
return
User avatar
PeterN
Posts: 366
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 171 times
Been thanked: 203 times
Contact:

Re: Two loops not working in 1.47.2 but ok in 1.44.2

Post by PeterN »

Hi Bugs
I can confirm this behavior.
Apparently, each "loop" remembers only the last seen inner "do" command line.
So my code example stays endlessly in the inner loop, because the outer "loop" in line 10 jumps to the inner "do" in line 4 and not in line 2

Code: [Local Link Removed for Guests]

x=0
do until x=5
  y=0
  do until y=2
    wlog x, y, "in loop #2"
    y=y+1
  loop
  wlog "after loop #2",x
  x=x+1
loop
wlog "after loop #1"
end
The wlog output is:

Code: [Local Link Removed for Guests]

0    0    in loop #2
0    1    in loop #2
after loop #2    0
after loop #2    1
after loop #2    2
after loop #2    3
after loop #2    4
after loop #2    5
after loop #2    6
after loop #2    7
...
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1260 times
Contact:

Re: Two loops not working in 1.47.2 but ok in 1.44.2

Post by cicciocb »

Thanks for your feedback,
I did some work on the loops and this seems a regression.
User avatar
PeterN
Posts: 366
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 171 times
Been thanked: 203 times
Contact:

Re: Two loops not working in 1.47.2 but ok in 1.44.2

Post by PeterN »

You can't make an omelet without breaking eggs :D
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1260 times
Contact:

Re: Two loops not working in 1.47.2 but ok in 1.44.2

Post by cicciocb »

[Local Link Removed for Guests] wrote: [Local Link Removed for Guests]Sat Nov 19, 2022 4:54 pm You can't make an omelet without breaking eggs :D
Yes, it seems a big omelette.
User avatar
PeterN
Posts: 366
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 171 times
Been thanked: 203 times
Contact:

Re: Two loops not working in 1.47.2 but ok in 1.44.2

Post by PeterN »

The omlet has a patient and capable cook after all
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1260 times
Contact:

Re: Two loops not working in 1.47.2 but ok in 1.44.2

Post by cicciocb »

In the while this is what will be possible to do with next release

https://wokwi.com/projects/348687290131808852

and

https://wokwi.com/projects/342961260497732178
User avatar
cicciocb
Site Admin
Posts: 1889
Joined: Mon Feb 03, 2020 1:15 pm
Location: Toulouse
Has thanked: 405 times
Been thanked: 1260 times
Contact:

Re: Two loops not working in 1.47.2 but ok in 1.44.2

Post by cicciocb »

Thanks a lot for your snippet,
I was able to find rapidly the issue, as often happens it was a question of "-1" somewhere in the code.
User avatar
PeterN
Posts: 366
Joined: Mon Feb 08, 2021 7:56 pm
Location: Krefeld, Germany
Has thanked: 171 times
Been thanked: 203 times
Contact:

Re: Two loops not working in 1.47.2 but ok in 1.44.2

Post by PeterN »

Fine that the omelette is OK now - I am dealing with a delicious lasagne right now :-)
bugs
Posts: 142
Joined: Mon Feb 08, 2021 10:10 pm
Location: Scotland
Has thanked: 44 times
Been thanked: 50 times

Re: Two loops not working in 1.47.2 but ok in 1.44.2

Post by bugs »

Glad to say both the loop and the serial2 problems tested ok in new ver 1.48.2
Thanks for the super-quick solutions. :D
Post Reply