[code]
...
var Flag1, Flag2, Flag3, ... : boolean; // Signalling flag "GLOBAL" variables (declared outside any procedure or function)
// You should give more meaningfull names to the signalling flags!
...
TimeCounter : word; // This is the extra "Counter Variable" as mentioned in the introduction
...
procedure interrupt
begin
if TimerX.InterruptFlag = 1 then // replace this name by the real name of the timer interrupt flag you use
begin
// ----- handle the Timebase ----- //
Inc(TimeCounter); // time goes by...
if TimeCounter > MaxTime // timecounter is with wrap around, the steps of it are from zero to MaxTime
then TimeCounter := 0; // e.g. if your timer interrupt is there every 0,5 secs, you can count from
// zero to 7200 (MaxTime in this case) to cover exactly one hour in steps of
// 0,5 secs.
// ----- do signalling to the main loop ----- //
if TimeCounter = 10 then Flag1 := true; // if the same values are used as above (0,5 sec timer interrupts) then
// this signal flag will be set after 5 seconds in the "timing sequence"
if TimeCounter = 240 then Flag2 := true; // if the same values are used as above (0,5 sec timer interrupts) then
// this signal flag will be set after 120 seconds (2 minutes) in the "timing sequence"
if TimeCounter = 3600 then Flag3 := true; // if the same values are used as above (0,5 sec timer interrupts) then
// this signal flag will be set after 1800 seconds (0,5 hours) in the "timing sequence"
if (TimeCounter mod 20) = 0 then Flag4 := true; // (*) if the same values are used as above (0,5 sec timer interrupts) then
// this signal flag will be set every 10 seconds
if (TimeCounter mod 600) = 0 then Flag5 := true; // (*) if the same values are used as above (0,5 sec timer interrupts) then
// this signal flag will be set every 5 minutes
if ... etc... // so depending on the timer interrupt rate and the value of the "TimeCounter"
// one can define easily when to set certain flags and in which order.
...
TimerX.InterruptFlag = 0; // reset the timer interrupt flag before returning from the interrupt service routine. (do not forget).
end;
end
[/code]