How to auto repeat the on mouseUp [SOLVED]

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

morrell
Posts: 84
Joined: Sat Dec 13, 2014 1:12 am

Re: How to auto repeat the on mouseUp

Post by morrell » Fri Jan 02, 2015 1:32 am

Thanks SparkOut and I will study it as we appear to be close to a result. It could be I'm getting very tired and need to look afresh in the morning and I will get back to you.

I do thank you for your time as I'm not the sharpest knife in the draw regarding LC.

Regards,

Ruth

morrell
Posts: 84
Joined: Sat Dec 13, 2014 1:12 am

Re: How to auto repeat the on mouseUp

Post by morrell » Fri Jan 02, 2015 9:43 am

I removed the 2 problem lines and all is now working.

However, before I go onto your If that works, then edit the on updateTheData handler with a check for valid integer value in the field

on clicking your message button this appears:-
6258,1420187535.991,updateTheData,card id 1283 of stack "C:/01 LIVE CODE/TESTXX.livecode"

Regards,

Ruth

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

Re: How to auto repeat the on mouseUp

Post by SparkOut » Fri Jan 02, 2015 9:56 am

Yes, that should be it. You were setting off an immediate updateTheData call, which set off another, which set off another until the engine gave up. You don't need to change the calculation code if you are sure there could never be anything but a single number in the field, but it would be good practice.
If you have a look at the sample stack you will also see a handler that cancels any outstanding update messages. The cancel button calls the handler, which is in the card script. This would be useful for you, since the cancel button may be pressed but an update might still be queued for quite some time.

morrell
Posts: 84
Joined: Sat Dec 13, 2014 1:12 am

Re: How to auto repeat the on mouseUp

Post by morrell » Fri Jan 02, 2015 10:18 am

I have now added:-

Code: Select all

      put field "EveryXMinutes" into tMins
      if (tMins is not an integer) or (tMins < 1) then
         put "Invalid interval" into field "EveryXMinutes"
         set the cUpdatesRunning of this card to false
         else
         send updateTheData to this card in (tMins * 60) seconds
      end if
      end if
end updateTheData
and all is OK again except your message box still reads:
6258,1420187535.991,updateTheData,card id 1283 of stack "C:/01 LIVE CODE/TESTXX.livecode" or is that not a problem?

I will do the Cancel button after reading the Sample Stack.

Regards,

Ruth

morrell
Posts: 84
Joined: Sat Dec 13, 2014 1:12 am

Re: How to auto repeat the on mouseUp

Post by morrell » Fri Jan 02, 2015 1:00 pm

EDITED: The text below in italics was my mistake in that I failed to open the correct file.
Well the sample stack written by Jaqueline and Kevin no doubt in any other person's hands other than mine is an excellent reference point. However, I have failed to find/understand what I should use to replace cUpdatesRunning which is presently coded in the Cancel button, namely:-

Code: Select all

on mouseUp
   set the cUpdatesRunning of this card to false
etc etc etc
go to card "xxxx"
end mouseUp
What should I replace it with?

Regards,

Ruth
Last edited by morrell on Fri Jan 02, 2015 2:47 pm, edited 1 time in total.

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

Re: How to auto repeat the on mouseUp

Post by SparkOut » Fri Jan 02, 2015 1:18 pm

Erm, I was referring to my sample stack I attached to my post above! :)

And yes, that pending message line just shows that it is working as it should. The next update is queued and only one at a time.
You can delete that button now you know the messages are working properly.

morrell
Posts: 84
Joined: Sat Dec 13, 2014 1:12 am

Re: How to auto repeat the on mouseUp [SOLVED]

Post by morrell » Fri Jan 02, 2015 3:06 pm

Sorry SparkOut both files had a similar name in my learning folder and yours really was self explanatory.

I do thank you for your time and patience, it was much appreciated and I can now move on to another issue which I have yet to solve.

Kind regards,

Ruth

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: How to auto repeat the on mouseUp [SOLVED]

Post by jacque » Fri Jan 02, 2015 7:29 pm

Ruth, do you understand the theory behind this method? It's a common way to trigger repeating events which can be generalized for many different purposes. You may need it again.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

morrell
Posts: 84
Joined: Sat Dec 13, 2014 1:12 am

Re: How to auto repeat the on mouseUp [SOLVED]

Post by morrell » Fri Jan 02, 2015 8:55 pm

Hello Jacqueline,

To be honest before reading what you just wrote, I would not have considered it for other repeating events and so those few words have again broadened my learning curve.

Regards,

Ruth

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: How to auto repeat the on mouseUp [SOLVED]

Post by jacque » Fri Jan 02, 2015 9:08 pm

If you have questions about what's happening, let us know and we'll explain. I not only admire your spirit, I want you to best your grandson. :)
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply