Screen freezes about 30 seconds after exiting repeat loop

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
CAsba
Posts: 423
Joined: Fri Sep 30, 2022 12:11 pm

Screen freezes about 30 seconds after exiting repeat loop

Post by CAsba » Mon Jun 09, 2025 1:08 pm

Hi,
I set up a repeat loop, 'repeat until fld "temp56" is 0', with a -1 negative adjustment to the value of fld "temp56" on each repeat. It works fine, negotiating a multitude of conditions, all correctly done. Then, when all is done (the loop moved lines of data from a DG to another DG), the screen freezes - that is, the screen greys out if the user tries to continue, for around 30 seconds. To try to troubleshoot what is happening, I inserted a line 'answer "...."' after the 'end repeat' line and before the 'exit mouseup' line; this line of script was never actioned. Any ideas anyone ?

stam
Posts: 3061
Joined: Sun Jun 04, 2006 9:39 pm

Re: Screen freezes about 30 seconds after exiting repeat loop

Post by stam » Mon Jun 09, 2025 3:02 pm

Personally I would insert a break point inside the loop and iterate a small number of time while watching each variable. Since this is not common behaviour it’s likely something with your code and following the code execution step by step is usually illuminating.

Alternatively, you could post your code here…

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10077
Joined: Fri Feb 19, 2010 10:17 am

Re: Screen freezes about 30 seconds after exiting repeat loop

Post by richmond62 » Mon Jun 09, 2025 3:51 pm

I inserted a line 'answer "...."' after the 'end repeat' line and before the 'exit mouseup' line; this line of script was never actioned.
This would seem to suggest that your repeat loop is going round in circles forever.

I am extremely skilled at doing this sort of thing: forgetting to insert something into my repeat loops so they stop repeating once some condition has been satisfied.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Screen freezes about 30 seconds after exiting repeat loop

Post by dunbarx » Mon Jun 09, 2025 4:52 pm

CAsba.
the screen freezes - that is, the screen greys out if the user tries to continue, for around 30 seconds.
And this happens after your code does what was intended??? This seems much different an issue than that your loop simply does not exit. Can you post the stack, or at least enough of it for us to examine?

Craig

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Re: Screen freezes about 30 seconds after exiting repeat loop

Post by SparkOut » Mon Jun 09, 2025 5:41 pm

Quite possibly the loop exit condition is not met because the subtraction of 1 per iteration is done with floating point arithmetic and the nearest the value gets to zero is only ever a very close approximation. Try making the repeat until check less than or equal to zero, not "exactly zero".
Also try adding a "wait 0 milliseconds with messages" line inside the repeat loop.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: Screen freezes about 30 seconds after exiting repeat loop

Post by FourthWorld » Mon Jun 09, 2025 6:42 pm

Without an example stack we're just guessing. With one we can probably resolve this in minutes.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Screen freezes about 30 seconds after exiting repeat loop

Post by dunbarx » Mon Jun 09, 2025 8:02 pm

What everyone said, but I am still worried about what I said, that is, the issue is spookier than simply a failure to exit a loop. That would seem like a "hang", not a greying out of the screen for half a minute.

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10077
Joined: Fri Feb 19, 2010 10:17 am

Re: Screen freezes about 30 seconds after exiting repeat loop

Post by richmond62 » Mon Jun 09, 2025 10:00 pm

I wonder if for some reason LC wasn't displaying the backdrop.

CAsba
Posts: 423
Joined: Fri Sep 30, 2022 12:11 pm

Re: Screen freezes about 30 seconds after exiting repeat loop

Post by CAsba » Tue Jun 10, 2025 8:48 am

Thanks everyone, I'll check out the 'zero' possibility. I made a workaround having discovered that the 'hang' occurs just before the processing of the last iteration. So I finish the loop before the last iteration, Repeat until check equals one, then do the last processing outside the loop. There was just too much coding, with references to other DG's to present the code.
Once again, thank you all for your interest.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10077
Joined: Fri Feb 19, 2010 10:17 am

Re: Screen freezes about 30 seconds after exiting repeat loop

Post by richmond62 » Tue Jun 10, 2025 10:20 am

I wish I could understand your reply: but I cannot.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Screen freezes about 30 seconds after exiting repeat loop

Post by dunbarx » Tue Jun 10, 2025 2:30 pm

CAsba.

I am with Richmond here. Are you saying that your repeat loop can successfully exit when the index counts down to 1, but cannot exit if the loop continues to count down one more iteration to zero?

I gotta see that code.

Craig

Post Reply