Re: What is the best way to trigger an action at a certain time?
Gentlemen, The trigger will be 'pulled' once or twice a day only -- so these external to LC options are also viable. Hadn't entered my head at all! Will be playing around with all these ideas and learn something! Basically use Macs, but have couple unused Windows laptops -- sounds like Task Scheduler and .bat files might be easier to deal with. Thanks. Tim On 2022.07.13 18:20, Ben Rubinstein via use-livecode wrote: Whatever works for your situation! At least one of my jobs, which runs a few times a week (pulling data from an internal system, generating and emailing a PDF report) has to launch fresh each time because of a bug in the graph widget which displays wrong if the script runs twice! There are others where the LC qpp is part of a dance in which other systems run before and after, so a batch script invoking each in turn is the thing that's scheduled. But of course there are contexts in which the best solution is an LC app waiting for a time or a command at which to leap into action. On 12/07/2022 22:56, Bob Sneidar via use-livecode wrote: Hmmm. Ok, but it seems having the LC app running invisibly all the time, listening for a command, something the cron service could do through the terminal easily enough, you could make it much more efficient. Just methods and madness I suppose. Bob S On Jul 12, 2022, at 13:15 , Ben Rubinstein via use-livecode wrote: I think I may not have been very clear. This isn't LiveCode doing anything special; just a standalone LiveCode app that either does something immediately on launch (and then quits), or inspects the command line parameters to decide what to do (and then quits). ___ 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: What is the best way to trigger an action at a certain time?
Whatever works for your situation! At least one of my jobs, which runs a few times a week (pulling data from an internal system, generating and emailing a PDF report) has to launch fresh each time because of a bug in the graph widget which displays wrong if the script runs twice! There are others where the LC qpp is part of a dance in which other systems run before and after, so a batch script invoking each in turn is the thing that's scheduled. But of course there are contexts in which the best solution is an LC app waiting for a time or a command at which to leap into action. On 12/07/2022 22:56, Bob Sneidar via use-livecode wrote: Hmmm. Ok, but it seems having the LC app running invisibly all the time, listening for a command, something the cron service could do through the terminal easily enough, you could make it much more efficient. Just methods and madness I suppose. Bob S On Jul 12, 2022, at 13:15 , Ben Rubinstein via use-livecode wrote: I think I may not have been very clear. This isn't LiveCode doing anything special; just a standalone LiveCode app that either does something immediately on launch (and then quits), or inspects the command line parameters to decide what to do (and then quits). ___ 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: What is the best way to trigger an action at a certain time?
Hmmm. Ok, but it seems having the LC app running invisibly all the time, listening for a command, something the cron service could do through the terminal easily enough, you could make it much more efficient. Just methods and madness I suppose. Bob S > On Jul 12, 2022, at 13:15 , Ben Rubinstein via use-livecode > wrote: > > I think I may not have been very clear. > > This isn't LiveCode doing anything special; just a standalone LiveCode app > that either does something immediately on launch (and then quits), or > inspects the command line parameters to decide what to do (and then quits). ___ 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: What is the best way to trigger an action at a certain time?
I think I may not have been very clear. This isn't LiveCode doing anything special; just a standalone LiveCode app that either does something immediately on launch (and then quits), or inspects the command line parameters to decide what to do (and then quits). I usually create a .bat file (on Windows) or .sh file (on Mac/Linux) to run the LC app with the appropriate parameters. On Windows you run the "Task Scheduler" and create a task to run the .bat file, with whatever schedules you like. On Mac/Linux you edit the 'crontab' file adding one or more lines with the interesting syntax to execute the .sh file. Your app can read the command line parameters (on Mac/Linux or Windows) by inspecting the special global variables $0, $1 etc. The only gotcha is that on Mac, you think your app is at e.g. /Users/yourname/Myapp - but actually on Mac what appears to be an application "Myapp" is a bundle (i.e. a folder with a special flag so the Finder pretends it's not), and the path to the executable app is e.g. /Users/yourname/Myapp.app/Contents/MacOS/Myapp On Linux and Windows, it's where you think it is! Ben On 12/07/2022 15:56, Bob Sneidar via use-livecode wrote: It seems to me that if you have an open socket to listen for commands, you could have the chron or windows scheduler send those commands to your LC app. Ben, some syntax would be helpful. Bob S On Jul 12, 2022, at 07:48 , Ben Rubinstein via use-livecode wrote: Hi Tim, On 11/07/2022 12:35, Tim Selander via use-livecode wrote: I want to have an LC app running on a computer doing nothing but watching the time. At predetermined times, I then want it to run a command. A call to an API on a website. My $0.02, FWIW: it this is really all your app is doing, and the times are every fee hours or days, rather than every few seconds, I would use the computer's built in scheduler to invoke your app, rather than have it running continuously and watching the time. I have a number of things like this - LC apps which are launched by schedule. On Windows, the Windows scheduler (I generally use a batch script which launches the app in this case); on Mac or Linux, use cron. I find this more reliable, easier to update etc. Ben ___ 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: What is the best way to trigger an action at a certain time?
It seems to me that if you have an open socket to listen for commands, you could have the chron or windows scheduler send those commands to your LC app. Ben, some syntax would be helpful. Bob S > On Jul 12, 2022, at 07:48 , Ben Rubinstein via use-livecode > wrote: > > Hi Tim, > > On 11/07/2022 12:35, Tim Selander via use-livecode wrote: >> I want to have an LC app running on a computer doing nothing but watching >> the time. At predetermined times, I then want it to run a command. A call to >> an API on a website. > > My $0.02, FWIW: it this is really all your app is doing, and the times are > every fee hours or days, rather than every few seconds, I would use the > computer's built in scheduler to invoke your app, rather than have it running > continuously and watching the time. > > I have a number of things like this - LC apps which are launched by schedule. > On Windows, the Windows scheduler (I generally use a batch script which > launches the app in this case); on Mac or Linux, use cron. I find this more > reliable, easier to update etc. > > Ben ___ 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: What is the best way to trigger an action at a certain time?
Hi Tim, On 11/07/2022 12:35, Tim Selander via use-livecode wrote: I want to have an LC app running on a computer doing nothing but watching the time. At predetermined times, I then want it to run a command. A call to an API on a website. My $0.02, FWIW: it this is really all your app is doing, and the times are every fee hours or days, rather than every few seconds, I would use the computer's built in scheduler to invoke your app, rather than have it running continuously and watching the time. I have a number of things like this - LC apps which are launched by schedule. On Windows, the Windows scheduler (I generally use a batch script which launches the app in this case); on Mac or Linux, use cron. I find this more reliable, easier to update etc. Ben ___ 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: What is the best way to trigger an action at a certain time?
I would suggest sending the "checkTime" message at the top of the handler in case something happens in --your code On Mon, Jul 11, 2022 at 11:28 AM Bob Sneidar via use-livecode < use-livecode@lists.runrev.com> wrote: > Slight improvement: > > local lInterval > constant cInterval = 300 > > on openStack >put cInterval into lInterval >checkTime > end openStack > > on checkTime >-- your code >send checkTime to me in lInterval seconds > end checkTime > > setProp interval, pInterval >if pInterval is empty then > ask "Enter a time interval in seconds:" as sheet > if the result is not "Cancel" and it is an integer and it >0 then \ > put it into lInterval >else > put pInterval into lInterval >end if > end interval > > Bob S > > > > On Jul 11, 2022, at 04:43 , Tore Nilsen via use-livecode < > use-livecode@lists.runrev.com> wrote: > > > > For this I would use a recursive approach with «send in time» something > like this: > > > > on openStack > >checkTime > > end openStack > > > > on checkTime > > ## Do your routines of checking time, performing the required action > etc. > > send checkTime to me in 300 seconds. ## you set the interval to > whatever is best for you > > end checkTime > > > > Best regards > > Tore Nilsen > > > >> 11. jul. 2022 kl. 13:35 skrev Tim Selander via use-livecode < > use-livecode@lists.runrev.com>: > >> > >> Dear all, > >> > >> I want to have an LC app running on a computer doing nothing but > watching the time. At predetermined times, I then want it to run a command. > A call to an API on a website. > >> > >> In the old HC days, I remember using "on idle" to watch for a set time. > But even then, using "on idle" was less than ideal. CPU hog. What is the > preferred/LC way to have an app trigger a command at a specific time of day? > >> > >> Any pointers appreciated! > >> > >> Tim Selander > >> Tokyo, Japan > >> > >> ___ > >> 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 > -- On the first day, God created the heavens and the Earth On the second day, God created the oceans. On the third day, God put the animals on hold for a few hours, and did a little diving. And God said, "This is good." ___ 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: What is the best way to trigger an action at a certain time?
Slight improvement: local lInterval constant cInterval = 300 on openStack put cInterval into lInterval checkTime end openStack on checkTime -- your code send checkTime to me in lInterval seconds end checkTime setProp interval, pInterval if pInterval is empty then ask "Enter a time interval in seconds:" as sheet if the result is not "Cancel" and it is an integer and it >0 then \ put it into lInterval else put pInterval into lInterval end if end interval Bob S > On Jul 11, 2022, at 04:43 , Tore Nilsen via use-livecode > wrote: > > For this I would use a recursive approach with «send in time» something like > this: > > on openStack >checkTime > end openStack > > on checkTime > ## Do your routines of checking time, performing the required action etc. > send checkTime to me in 300 seconds. ## you set the interval to whatever is > best for you > end checkTime > > Best regards > Tore Nilsen > >> 11. jul. 2022 kl. 13:35 skrev Tim Selander via use-livecode >> : >> >> Dear all, >> >> I want to have an LC app running on a computer doing nothing but watching >> the time. At predetermined times, I then want it to run a command. A call to >> an API on a website. >> >> In the old HC days, I remember using "on idle" to watch for a set time. But >> even then, using "on idle" was less than ideal. CPU hog. What is the >> preferred/LC way to have an app trigger a command at a specific time of day? >> >> Any pointers appreciated! >> >> Tim Selander >> Tokyo, Japan >> >> ___ >> 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: What is the best way to trigger an action at a certain time?
I've got a library for adding CRON functionality, if you want something more elaborate. https://github.com/macMikey/mikeys-cron-library On Mon, Jul 11, 2022 at 7:48 AM Tim Selander via use-livecode < use-livecode@lists.runrev.com> wrote: > Tore, > > Interesting! 'send in time' is a new one for me. > Thanks! > > Tim > > On 2022.07.11 20:43, Tore Nilsen via use-livecode wrote: > > For this I would use a recursive approach with «send in time» something > like this: > > > > on openStack > > checkTime > > end openStack > > > > on checkTime > >## Do your routines of checking time, performing the required action > etc. > >send checkTime to me in 300 seconds. ## you set the interval to > whatever is best for you > > end checkTime > > > > Best regards > > Tore Nilsen > > > >> 11. jul. 2022 kl. 13:35 skrev Tim Selander via use-livecode < > use-livecode@lists.runrev.com>: > >> > >> Dear all, > >> > >> I want to have an LC app running on a computer doing nothing but > watching the time. At predetermined times, I then want it to run a command. > A call to an API on a website. > >> > >> In the old HC days, I remember using "on idle" to watch for a set time. > But even then, using "on idle" was less than ideal. CPU hog. What is the > preferred/LC way to have an app trigger a command at a specific time of day? > >> > >> Any pointers appreciated! > >> > >> Tim Selander > >> Tokyo, Japan > >> > >> ___ > >> 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 > -- On the first day, God created the heavens and the Earth On the second day, God created the oceans. On the third day, God put the animals on hold for a few hours, and did a little diving. And God said, "This is good." ___ 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: What is the best way to trigger an action at a certain time?
Tore, Interesting! 'send in time' is a new one for me. Thanks! Tim On 2022.07.11 20:43, Tore Nilsen via use-livecode wrote: For this I would use a recursive approach with «send in time» something like this: on openStack checkTime end openStack on checkTime ## Do your routines of checking time, performing the required action etc. send checkTime to me in 300 seconds. ## you set the interval to whatever is best for you end checkTime Best regards Tore Nilsen 11. jul. 2022 kl. 13:35 skrev Tim Selander via use-livecode : Dear all, I want to have an LC app running on a computer doing nothing but watching the time. At predetermined times, I then want it to run a command. A call to an API on a website. In the old HC days, I remember using "on idle" to watch for a set time. But even then, using "on idle" was less than ideal. CPU hog. What is the preferred/LC way to have an app trigger a command at a specific time of day? Any pointers appreciated! Tim Selander Tokyo, Japan ___ 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: What is the best way to trigger an action at a certain time?
For this I would use a recursive approach with «send in time» something like this: on openStack checkTime end openStack on checkTime ## Do your routines of checking time, performing the required action etc. send checkTime to me in 300 seconds. ## you set the interval to whatever is best for you end checkTime Best regards Tore Nilsen > 11. jul. 2022 kl. 13:35 skrev Tim Selander via use-livecode > : > > Dear all, > > I want to have an LC app running on a computer doing nothing but watching the > time. At predetermined times, I then want it to run a command. A call to an > API on a website. > > In the old HC days, I remember using "on idle" to watch for a set time. But > even then, using "on idle" was less than ideal. CPU hog. What is the > preferred/LC way to have an app trigger a command at a specific time of day? > > Any pointers appreciated! > > Tim Selander > Tokyo, Japan > > ___ > 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