Re: Count Up Timer?
Ok, thanks Sean, here it is in plain text for anyone who wants to use it. function TimeDisplay HowMany,DisplayHow if DisplayHow = "Duration" then //* if AppStarterStackSettings["default"]["Time Unit"] = "seconds" then return round(HowMany / 1000,3) & "s" else if AppStarterStackSettings["default"]["Time Unit"] = "milliseconds" then return HowMany & "ms" else if AppStarterStackSettings["default"]["Time Unit"] = "microseconds" then end if else if DisplayHow = "Human Readable" then //* local final_output = " days ::" local running_second_count local next_calculation set itemdelimiter to "." -- we are looking at boths sides of the decimal place put round(HowMany / 1000) into HowMany -- convert to seconds // 86,400 seconds in an day // 3600 in an hour // 60 seonds in a minute // replace counts as you go -- days put HowMany / 86400 into next_calculation if next_calculation < 1 then put HowMany into running_second_count replace "" with "0" in final_output else // how many days? replace "" with item 1 of next_calculation in final_output put (HowMany) - (item 1 of next_calculation * 86400) into running_second_count end if -- hours put running_second_count / 3600 into next_calculation if next_calculation < 1 then replace "" with "00" in final_output else // how many hours? if the number of characters in item 1 of next_calculation = 1 then replace "" with "0" & item 1 of next_calculation in final_output else replace "" with item 1 of next_calculation in final_output end if put (running_second_count) - (item 1 of next_calculation * 3600) into running_second_count end if -- minutes put running_second_count / 60 into next_calculation if next_calculation < 1 then replace "" with "00" in final_output else // how many minutes? if the number of characters in item 1 of next_calculation = 1 then replace "" with "0" & item 1 of next_calculation in final_output else replace "" with item 1 of next_calculation in final_output end if put (running_second_count) - (item 1 of next_calculation * 60) into running_second_count end if -- seconds put running_second_count into next_calculation if next_calculation < 1 then replace "" with "00" in final_output else // how many minutes? if the number of characters in item 1 of next_calculation = 1 then replace "" with "0" & next_calculation in final_output else replace "" with next_calculation in final_output end if end if end if //* return final_output end TimeDisplay ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Count Up Timer?
When I was very young I used to run a gadget like this on a field with styled text: on mouseUp get fld 1 repeat for each char tChar in it put numToChar(charToNum(tChar)) after accum end repeat put accum into fld 2 end mouseUp But you do not have to do all that: on mouseUp get fld 1 put it into fld 2 end mouseUp I suppose when you put styled text into a variable, unless you play with the HTMLText, only plain text can be held there. Craig > On Nov 2, 2021, at 1:27 PM, Sean Cole via use-livecode > wrote: > > Tom, > It is. > I would copy it into TextEdit (Plaintext), Atom or BBEdit first to strip > any formatting properly, then copy paste from there to mail. :) > It happens. Nothing to worry about and only a minor inconvenience. > Good code, though :) > Sean > > > On Tue, 2 Nov 2021 at 17:14, Tom Glod via use-livecode < > use-livecode@lists.runrev.com> wrote: > >> Oh man ..I forgot about the formatting thing. >> In my client it shows up formatted with color. >> Does it work ok if it is pasted plain text? >> >> On Tue, Nov 2, 2021 at 12:08 PM Mark Wieder via use-livecode < >> use-livecode@lists.runrev.com> wrote: >> >>> On 11/2/21 8:48 AM, Craig Newman via use-livecode wrote: Mark. “... unless the person was born after 1 January 1970." Check out the thread “When was the big bang?” on the forum: >>> >> https://forums.livecode.com/viewtopic.php?f=9=26619=138530=big+bang#p138530 >>> >>> LOL. "one bit for (the) apple." >>> >>> -- >>> Mark Wieder >>> ahsoftw...@gmail.com >>> >>> ___ >>> use-livecode mailing list >>> use-livecode@lists.runrev.com >>> Please visit this url to subscribe, unsubscribe and manage your >>> subscription preferences: >>> http://lists.runrev.com/mailman/listinfo/use-livecode >>> >> >> >> -- >> Tom Glod >> Founder & Developer >> MakeShyft R.D.A (www.makeshyft.com) >> Mobile:647.562.9411 >> ___ >> use-livecode mailing list >> use-livecode@lists.runrev.com >> Please visit this url to subscribe, unsubscribe and manage your >> subscription preferences: >> http://lists.runrev.com/mailman/listinfo/use-livecode >> > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Count Up Timer?
Tom, It is. I would copy it into TextEdit (Plaintext), Atom or BBEdit first to strip any formatting properly, then copy paste from there to mail. :) It happens. Nothing to worry about and only a minor inconvenience. Good code, though :) Sean On Tue, 2 Nov 2021 at 17:14, Tom Glod via use-livecode < use-livecode@lists.runrev.com> wrote: > Oh man ..I forgot about the formatting thing. > In my client it shows up formatted with color. > Does it work ok if it is pasted plain text? > > On Tue, Nov 2, 2021 at 12:08 PM Mark Wieder via use-livecode < > use-livecode@lists.runrev.com> wrote: > > > On 11/2/21 8:48 AM, Craig Newman via use-livecode wrote: > > > Mark. > > > > > > “... unless the person was born after 1 January 1970." > > > > > > Check out the thread “When was the big bang?” on the forum: > > > > > > > > > https://forums.livecode.com/viewtopic.php?f=9=26619=138530=big+bang#p138530 > > > > LOL. "one bit for (the) apple." > > > > -- > > Mark Wieder > > ahsoftw...@gmail.com > > > > ___ > > use-livecode mailing list > > use-livecode@lists.runrev.com > > Please visit this url to subscribe, unsubscribe and manage your > > subscription preferences: > > http://lists.runrev.com/mailman/listinfo/use-livecode > > > > > -- > Tom Glod > Founder & Developer > MakeShyft R.D.A (www.makeshyft.com) > Mobile:647.562.9411 > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Count Up Timer?
Oh man ..I forgot about the formatting thing. In my client it shows up formatted with color. Does it work ok if it is pasted plain text? On Tue, Nov 2, 2021 at 12:08 PM Mark Wieder via use-livecode < use-livecode@lists.runrev.com> wrote: > On 11/2/21 8:48 AM, Craig Newman via use-livecode wrote: > > Mark. > > > > “... unless the person was born after 1 January 1970." > > > > Check out the thread “When was the big bang?” on the forum: > > > > > https://forums.livecode.com/viewtopic.php?f=9=26619=138530=big+bang#p138530 > > LOL. "one bit for (the) apple." > > -- > Mark Wieder > ahsoftw...@gmail.com > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > -- Tom Glod Founder & Developer MakeShyft R.D.A (www.makeshyft.com) Mobile:647.562.9411 ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Count Up Timer?
On 11/2/21 8:48 AM, Craig Newman via use-livecode wrote: Mark. “... unless the person was born after 1 January 1970." Check out the thread “When was the big bang?” on the forum: https://forums.livecode.com/viewtopic.php?f=9=26619=138530=big+bang#p138530 LOL. "one bit for (the) apple." -- Mark Wieder ahsoftw...@gmail.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Count Up Timer?
And then if you want to convert to the Babalonian calendar of 360 days in a year, well that is just right out. Bob S > On Nov 2, 2021, at 08:48 , Craig Newman via use-livecode > wrote: > > Mark. > > “... unless the person was born after 1 January 1970." > > Check out the thread “When was the big bang?” on the forum: > > https://forums.livecode.com/viewtopic.php?f=9=26619=138530=big+bang#p138530 > > Craig > >> On Nov 2, 2021, at 11:43 AM, Mark Wieder via use-livecode >> wrote: >> >> On 11/2/21 7:33 AM, Curry Kenworthy via use-livecode wrote: >> >>> A forum is handy for searches, >>> so a nice place to visit now and then. >>> But I wouldn't want to live there! :D >> >> Heh. My thoughts as well. >> It would take a lot of work to reformat the OP’s code example into something workable in the SE. >>> I thought the OP was Dan, but you mean Tom's function? >>> Just a matter of not pasting **styled** text for code. >>> Even then, it's easily put right with a few commands. >>> Mark's example is easy to follow too. >> >> But I think neither of these will solve the OP's question unless the person >> was born after 1 January 1970. >> >> -- >> Mark Wieder >> ahsoftw...@gmail.com >> >> ___ >> use-livecode mailing list >> use-livecode@lists.runrev.com >> Please visit this url to subscribe, unsubscribe and manage your subscription >> preferences: >> http://lists.runrev.com/mailman/listinfo/use-livecode > > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Count Up Timer?
Tidy. Took 10 seconds: -- function TimeDisplay HowMany,DisplayHow if DisplayHow = "Duration" then // if AppStarterStackSettings["default"]["Time Unit"] = "seconds" then return round(HowMany / 1000,3) & "s" else if AppStarterStackSettings["default"]["Time Unit"] = "milliseconds" then return HowMany & "ms" else if AppStarterStackSettings["default"]["Time Unit"] = "microseconds" then end if else if DisplayHow = "Human Readable" then // local final_output = " days ::" local running_second_count local next_calculation set itemdelimiter to "." -- we are looking at boths sides of the decimal place put round(HowMany / 1000) into HowMany -- convert to seconds // 86,400 seconds in an day // 3600 in an hour // 60 seonds in a minute // replace counts as you go -- days put HowMany / 86400 into next_calculation if next_calculation < 1 then put HowMany into running_second_count replace "" with "0" in final_output else // how many days? replace "" with item 1 of next_calculation in final_output put (HowMany) - (item 1 of next_calculation * 86400) into running_second_count end if -- hours put running_second_count / 3600 into next_calculation if next_calculation < 1 then replace "" with "00" in final_output else // how many hours? if the number of characters in item 1 of next_calculation = 1 then replace "" with "0" & item 1 of next_calculation in final_output else replace "" with item 1 of next_calculation in final_output end if put (running_second_count) - (item 1 of next_calculation * 3600) into running_second_count end if -- minutes put running_second_count / 60 into next_calculation if next_calculation < 1 then replace "" with "00" in final_output else // how many minutes? if the number of characters in item 1 of next_calculation = 1 then replace "" with "0" & item 1 of next_calculation in final_output else replace "" with item 1 of next_calculation in final_output end if put (running_second_count) - (item 1 of next_calculation * 60) into running_second_count end if -- seconds put running_second_count into next_calculation if next_calculation < 1 then replace "" with "00" in final_output else // how many minutes? if the number of characters in item 1 of next_calculation = 1 then replace "" with "0" & next_calculation in final_output else replace "" with next_calculation in final_output end if end if end if // return final_output end TimeDisplay --- ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Count Up Timer?
Mark. “... unless the person was born after 1 January 1970." Check out the thread “When was the big bang?” on the forum: https://forums.livecode.com/viewtopic.php?f=9=26619=138530=big+bang#p138530 Craig > On Nov 2, 2021, at 11:43 AM, Mark Wieder via use-livecode > wrote: > > On 11/2/21 7:33 AM, Curry Kenworthy via use-livecode wrote: > >> A forum is handy for searches, >> so a nice place to visit now and then. >> But I wouldn't want to live there! :D > > Heh. My thoughts as well. > >> > It would take a lot of work to reformat the OP’s code example >> > into something workable in the SE. >> I thought the OP was Dan, but you mean Tom's function? >> Just a matter of not pasting **styled** text for code. >> Even then, it's easily put right with a few commands. >> Mark's example is easy to follow too. > > But I think neither of these will solve the OP's question unless the person > was born after 1 January 1970. > > -- > Mark Wieder > ahsoftw...@gmail.com > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Count Up Timer?
On 11/2/21 7:33 AM, Curry Kenworthy via use-livecode wrote: A forum is handy for searches, so a nice place to visit now and then. But I wouldn't want to live there! :D Heh. My thoughts as well. > It would take a lot of work to reformat the OP’s code example > into something workable in the SE. I thought the OP was Dan, but you mean Tom's function? Just a matter of not pasting **styled** text for code. Even then, it's easily put right with a few commands. Mark's example is easy to follow too. But I think neither of these will solve the OP's question unless the person was born after 1 January 1970. -- Mark Wieder ahsoftw...@gmail.com ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Count Up Timer?
Craig: > This is just another great example why the Forum > is so much better a venue than this list. My view is exactly opposite; I like a List s much better. A forum is handy for searches, so a nice place to visit now and then. But I wouldn't want to live there! :D > It would take a lot of work to reformat the OP’s code example > into something workable in the SE. I thought the OP was Dan, but you mean Tom's function? Just a matter of not pasting **styled** text for code. Even then, it's easily put right with a few commands. Mark's example is easy to follow too. List is a great venue! Always part of the LC experience. But I'm glad we have both to suit everyone. Best wishes, Curry Kenworthy Custom Software Development "Better Methods, Better Results" Christian LiveCode Training and Consulting http://livecodeconsulting.com/ ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Count Up Timer?
Sheesh. This is just another great example why the Forum is so much better a venue than this list. It would take a lot of work to reformat the OP’s code example into something workable in the SE. Craig > On Nov 1, 2021, at 6:29 PM, Mark Smith via use-livecode > wrote: > > You want the convert command. convert 1605553200 from seconds to dateitems > gives you 2020,11,16,19,0,0,2 (lookup dateitems). convert the date && the > time to seconds gives the date/time right now = 1635805440, then do the same > as step one with that gives you 2021,11,1,22,24,0,2. Do a little subtraction > and you get 1 yr, 0 months, 15 days, 3 hours, 24 mins, 0 secs. > >> On Nov 1, 2021, at 9:45 PM, Dan Friedman via use-livecode >> wrote: >> >> Anyone ever done a count up timer? For example, if we supply the seconds >> of 1605553200, we want to display the number of years, months, days, hours, >> minutes and seconds since that time. For example, "How long have you been >> alive?". This needs to be precise – need to account for leap years, days >> in month, etc. >> >> Save me!! :) >> >> -Dan >> >> ___ >> use-livecode mailing list >> use-livecode@lists.runrev.com >> Please visit this url to subscribe, unsubscribe and manage your subscription >> preferences: >> http://lists.runrev.com/mailman/listinfo/use-livecode > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Count Up Timer?
You want the convert command. convert 1605553200 from seconds to dateitems gives you 2020,11,16,19,0,0,2 (lookup dateitems). convert the date && the time to seconds gives the date/time right now = 1635805440, then do the same as step one with that gives you 2021,11,1,22,24,0,2. Do a little subtraction and you get 1 yr, 0 months, 15 days, 3 hours, 24 mins, 0 secs. > On Nov 1, 2021, at 9:45 PM, Dan Friedman via use-livecode > wrote: > > Anyone ever done a count up timer? For example, if we supply the seconds of > 1605553200, we want to display the number of years, months, days, hours, > minutes and seconds since that time. For example, "How long have you been > alive?". This needs to be precise – need to account for leap years, days in > month, etc. > > Save me!! :) > > -Dan > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your subscription > preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
Re: Count Up Timer?
Hey Dan, I'm pretty sure this handler works. But it only does Days, Hours,Minutes and Seconds. I'm sure you can add to it. (human readable section) Cheers, Tom -- *function* TimeDisplay HowMany,DisplayHow *if* DisplayHow = "Duration" *then* *//** *if* AppStarterStackSettings["default"]["Time Unit"] = "seconds" *then* *return* round(HowMany / 1000,3) & "s" *else* *if* AppStarterStackSettings["default"]["Time Unit"] = "milliseconds" *then* *return* HowMany & "ms" *else* *if* AppStarterStackSettings["default"]["Time Unit"] = "microseconds" *then* *end* *if* *else* *if* DisplayHow = "Human Readable" *then* *//** *local* final_output = " days ::" *local* running_second_count *local* next_calculation *set* itemdelimiter to "." *-- we are looking at boths sides of the decimal place* *put* round(HowMany / 1000) into HowMany *-- convert to seconds* *// 86,400 seconds in an day* *// 3600 in an hour* *// 60 seonds in a minute* *// replace counts as you go* *-- days* *put* HowMany / 86400 into next_calculation *if* next_calculation < 1 *then* *put* HowMany into running_second_count *replace* "" with "0" in final_output *else* *// how many days?* *replace* "" with item 1 of next_calculation in final_output *put* (HowMany) - (item 1 of next_calculation * 86400) into running_second_count *end* *if* *-- hours* *put* running_second_count / 3600 into next_calculation *if* next_calculation < 1 *then* *replace* "" with "00" in final_output *else* *// how many hours?* *if* the number of characters in item 1 of next_calculation = 1 *then* *replace* "" with "0" & item 1 of next_calculation in final_output *else* *replace* "" with item 1 of next_calculation in final_output *end* *if* *put* (running_second_count) - (item 1 of next_calculation * 3600) into running_second_count *end* *if* *-- minutes* *put* running_second_count / 60 into next_calculation *if* next_calculation < 1 *then* *replace* "" with "00" in final_output *else* *// how many minutes?* *if* the number of characters in item 1 of next_calculation = 1 *then* *replace* "" with "0" & item 1 of next_calculation in final_output *else* *replace* "" with item 1 of next_calculation in final_output *end* *if* *put* (running_second_count) - (item 1 of next_calculation * 60) into running_second_count *end* *if* *-- seconds* *put* running_second_count into next_calculation *if* next_calculation < 1 *then* *replace* "" with "00" in final_output *else* *// how many minutes?* *if* the number of characters in item 1 of next_calculation = 1 *then* *replace* "" with "0" & next_calculation in final_output *else* *replace* "" with next_calculation in final_output *end* *if* *end* *if* *end* *if* *//** *return* final_output *end* TimeDisplay --- On Mon, Nov 1, 2021 at 5:47 PM Dan Friedman via use-livecode < use-livecode@lists.runrev.com> wrote: > Anyone ever done a count up timer? For example, if we supply the seconds > of 1605553200, we want to display the number of years, months, days, hours, > minutes and seconds since that time. For example, "How long have you been > alive?". This needs to be precise – need to account for leap years, days > in month, etc. > > Save me!! :) > > -Dan > > ___ > use-livecode mailing list > use-livecode@lists.runrev.com > Please visit this url to subscribe, unsubscribe and manage your > subscription preferences: > http://lists.runrev.com/mailman/listinfo/use-livecode > -- Tom Glod Founder & Developer MakeShyft R.D.A (www.makeshyft.com) Mobile:647.562.9411 ___ use-livecode mailing list use-livecode@lists.runrev.com Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode