Jump to content
Delphi65

How to check and set

Recommended Posts

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
8 minutes ago, Lars Fosdal said:

Which version of Delphi?

I am being very terse, since doing is learning.
 

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 by Delphi65
need to add more

Share this post


Link to post

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×