Page 1 of 1

How to run code on start up

Posted: Sun Nov 15, 2015 7:34 pm
by UtahCode197
I want to run some code (a clock) as soon as the program starts (ie not have to have a button pressed for the code to start). Is there a way to do this?
Thanks

Re: How to run code on start up

Posted: Sun Nov 15, 2015 7:48 pm
by quailcreek
You could put the code in an openStack or preOpenStack script in a stack script.

Re: How to run code on start up

Posted: Sun Nov 15, 2015 8:10 pm
by UtahCode197
Thanks for your reply!
I now have this code and it keeps flashing between internet date and item 5 of internet date (the time)

Code: Select all

on preOpenStack
   set the flag of me to not the flag of me
   if the flag of me then startTimer
end preOpenStack
on startTimer
   set itemDelimiter to " "
   put item 5 of internet date into me
   if the flag of me then send startTimer to me in 0.5 second
end startTimer
I'm not sure how to fix this. Is there a way?

Re: How to run code on start up

Posted: Sun Nov 15, 2015 8:54 pm
by Simon
Hi Rory,
I just put all of this into a stack script;

Code: Select all

on preOpenStack
   set the flag of me to not the flag of me
   if the flag of me then startTimer
end preOpenStack

on startTimer
   set itemDelimiter to " "
   put item 5 of internet date
   if the flag of me then send startTimer to me in 0.5 second
end startTimer

on mouseUp
      preOpenStack
end mouseUp
It worked fine for me, LiveCode 7.1 Win 7

I will say that there was a recent post in which the coder stated that running a script like this all day would end up I think 2 minutes off at the end of the day. It took stopping the timer and restarting it to sync up.

Simon