Delphi65 0 Posted January 4, 2023 Dear all, I am trying to run a schedule as following where i have: Checkbox (if the schedule is enabled for the day or not, every day has it's own checkbox such as: checkboxMonday, checkboxTuesday etc.) Time field (edit showing now) Day field (memo showing the today) Time field (showing at what time to run the schedule) Now, any ideas of how to combine all this inside one procedure? What i am chasing is something like this: Procedure Tform1.CollectData; begin if checkboxMonday is checked and memofield is showing "Monday" and TimeNow is equal to TimeMonday then begin CollectData; end else ShowMessage('Event is not scheduled'); end; Is this possible? If not, what do i need? Thanks for all the answers. Share this post Link to post
Lars Fosdal 1792 Posted January 4, 2023 Which version of Delphi? I am being very terse, since doing is learning. Checkbox.Checked gives you the boolean state of the checkbox MemoField.Text returns the text where you have the day See https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Date_and_Time_Support for how to compare timestamps Share this post Link to post
Delphi65 0 Posted January 4, 2023 (edited) 8 minutes ago, Lars Fosdal said: Which version of Delphi? I am being very terse, since doing is learning. Checkbox.Checked gives you the boolean state of the checkbox MemoField.Text returns the text where you have the day See https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Date_and_Time_Support for how to compare timestamps Thank you! I am using Delphi Berlin. Yes, my memo gives me the day, and my checkbox tell me if the event is set or not. I have my time edit also which gives me the current time. I am planning to use a timer to do the checks. If the event is enabled, it will check the day and time and if the enabled day and time matches with the current day and time, it will run the event. I have all the required data, i just need to figure out how to run the event because i need to make sure the current day and time matches with the day and time behind that checkbox which is enabled. Or if you have any suggestions of how to do this schedule daily at selected time, please shoot me. Edited January 4, 2023 by Delphi65 need to add more Share this post Link to post
Lars Fosdal 1792 Posted January 4, 2023 My own scheduler loads a config, and has events added dynamically based on the config settings. Config-wise, events can be oneshot or repeating. My settings allows for fixed intervals, or specific timeslots during a day. The settings are parsed and a scheduler, which basically is a list of times and what is supposed to happened at that time, is rebuilt on startup and at midnight for today's events. Events that are in past time are removed. It also add specific built in events such as weekly events or overnight events. Basically, your timer would then look up "Now" and compare it to the sorted list of events in the scheduler. If "Now" > "Event.Time", trigger the event and remove the entry from the scheduler. In my case, it creates threads specific to the event. How frequently you need to check "Now" and scan the events, depends on how urgent it is that the event happens on time. Share this post Link to post
Delphi65 0 Posted January 4, 2023 24 minutes ago, Lars Fosdal said: My own scheduler loads a config, and has events added dynamically based on the config settings. Config-wise, events can be oneshot or repeating. My settings allows for fixed intervals, or specific timeslots during a day. The settings are parsed and a scheduler, which basically is a list of times and what is supposed to happened at that time, is rebuilt on startup and at midnight for today's events. Events that are in past time are removed. It also add specific built in events such as weekly events or overnight events. Basically, your timer would then look up "Now" and compare it to the sorted list of events in the scheduler. If "Now" > "Event.Time", trigger the event and remove the entry from the scheduler. In my case, it creates threads specific to the event. How frequently you need to check "Now" and scan the events, depends on how urgent it is that the event happens on time. Thanks Lars! Yes, correct, my timer will look up for "Now" and compare. The events will happen only once a day that could be for example today Wednesday at 20:15. I could however make my timer to check once every 10 minutes. My event time slots are also specific, they will be different for each day. Share this post Link to post