Page 1 of 1
Button press every 3 seconds without freezing?
Posted: Mon Feb 12, 2024 8:19 pm
by DorianReedBased
Im trying to make it so a button can only be pressed every 3 seconds, how would i do this without using the wait command (it freezes the whole stack), thanks in advance

Re: Button press every 3 seconds without freezing?
Posted: Mon Feb 12, 2024 8:54 pm
by bn
Hi DorianReedBased,
welcome to the forum.
I made a stack that shows one way of preventing a button to fire in less than 3 seconds from the last click.
It uses a 'script local variable' to store the time of the last click.
Such a variable must be declared outside and above of a handler hat uses it. Usually you declare them at the top of the script.
That variable is instantiated with 0. When the button is clicked the milliseconds are stored in the script local variable 'sLastClickTime'
The mouseUp handler checks the interval (3000 milliseconds) and if the time is passed that value then it fires.
Have a look at the script of the button.
Kind regards
Bernd
Re: Button press every 3 seconds without freezing?
Posted: Mon Feb 12, 2024 9:46 pm
by dunbarx
Bernd.
Sure the name of your demo stack is long enough?
Craig
Re: Button press every 3 seconds without freezing?
Posted: Mon Feb 12, 2024 9:49 pm
by bn
dunbarx wrote: ↑Mon Feb 12, 2024 9:46 pm
Bernd.
Sure the name of your demo stack is long enough?
Craig
No, but I ran out of words...
Kind regards
Bernd
Re: Button press every 3 seconds without freezing?
Posted: Mon Feb 12, 2024 9:57 pm
by dunbarx
I understand.
But couldn't you at least have made it more descriptive?
Craig
Re: Button press every 3 seconds without freezing?
Posted: Mon Feb 12, 2024 10:06 pm
by bn
dunbarx wrote: ↑Mon Feb 12, 2024 9:57 pm
I understand.
But couldn't you at least have made it more descriptive?
Craig
Ok, I am always aiming for baroque titles about half a page long.
How about
This is the story of a press-down device that executes your wishes that you have put into the device in a language they call 'LiveCode' and that will not work unless you waited for at least 3 grains of sand down the hour glass. But then by mysterious magic it will execute the exact same orders it did before.
Kind regards
Bernd
Re: Button press every 3 seconds without freezing?
Posted: Mon Feb 12, 2024 10:22 pm
by dunbarx
Bernd.
Too long.
Craig
Re: Button press every 3 seconds without freezing?
Posted: Tue Feb 13, 2024 6:57 pm
by jacque

What would I do without you guys. The seriousness and depth of your contributions is uplifting.