Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 164
  • Last Modified:

Using the timer

I work on a helpdesk. I get regular calls throughout the day. I want to be able to add a persons name into my program and then 30 minutes after this name will pop up on screen as a reminder to myself to deal with his problem. I can do this but after his call I may have entered 5 other calls that also have to pop up after the required time.
Any help or code would be appreciated.
Cheers
Mike Ross
0
mykyl
Asked:
mykyl
  • 7
  • 2
  • 2
  • +5
1 Solution
 
rene100Commented:
hi mike

her's an idea:
make an integer-array and a string-array.
fill the string-array with the name of the persons, and
the integer-array with the seconds (or minutes) remaining for
the pop-up menu.
the on overy OnTimer procedure, you decrement the amount in the
int-array, and if it is zero, the pop-up is displayed with the name in the string-array

regards
rene
0
 
viktornetCommented:
you could also create a record...

type
  TPerson = record
    Name : String;
    Time : Integer;
end;

var
  People : array[0..500] of TPerson;
To Clear the Arra()
for i := 0 to 500 do
begin
  People[i].Name := '';
  People[i].Time := 0;
end;

//If there is a new person to add then....
for i := 0 to 500 do
  if (People[i].Name = '')and(People[i].Time = 0)then
  begin
    People[i].Name := TheName;
    People[i].Time := 30;
    break;
  end;

Make a function that decreases the time...

for i := to numpeople do
  if Not(People[i].Time = 0)then
    Dec(Peopl[i].Time);

there are a few more things you have to think about but don't have much time right noe///

Hope this helps a bit....

Regards,
Viktor Ivanov
0
 
viktornetCommented:
One more thing to add.....This code I gave you above for decreasing the time has to be in the ontimer of the timer....I'll add some code here to display his/her name if the time is 0

for i := to numpeople do
begin
  if Not(People[i].Time = 0)then
         Dec(Peopl[i].Time)
  else
    if Not(People[i].Name = '') then
      ShowMessage('Time to get with ' + People[i].Name + ' and fix his/her problems!');
end;

Regards,
Viktor Ivanov
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
MadshiCommented:
Sorry guys, I would prefer using winAPI SetTimer/KillTimer directly:

var NameRec : array of record   // dynamic array (Delphi 4)
                         id   : cardinal;
                         name : string;
                       end;

procedure TimerProc(hwnd: HWND; uMsg, idEvent: cardinal; dwTime: cardinal); stdcall;
begin
  KillTimer(0,idEvent);
  for i1:=0 to NoOfNames-1 do
    if NameRec[i1].id:=idEvent then begin
      YourProcedureToPopupTheName(NameRec[i1].name);
      break;
    end;
end;

procedure AddName(name: string);
begin
  SetLength(NameRec,NoOfNames+1);
  NameRec[NoOfNames].name:=name;
  NameRec[NoOfNames].id:=SetTimer(0,0,ms,@TimerProc);
  inc(NoOfNames);
end;

Regards, Madshi.
0
 
viktornetCommented:
That's a good one too...Haven't tested it, but if it works I guess it's cool too,,, You can also have a StringList with the name and the time.....

List.Add(Name + '-'+IntToStr(TheTime));

//Vik
0
 
scrapdogCommented:
Since, I would assume that 30 minutes doesn't have to be EXACT in your case (i.e. 29 minutes or 31 minutes would be OK), you could set the timer to an interval of one minute.

With the person's record, include the system date/time when the call occurred.  Then, every minute that the OnTimer event occurs, compare the current system date/time with that of the date/time attached to every call.  If 30 minutes has elapsed, pop up the reminder for that call.

This would eliminate the need to use counters of any kind.  You could set the TTimer to any interval.  If you need more precision, you can decrease the TTimer interval.  For example you could set the interval to thirty seconds (the reminder would be shown sometime between 29:30 and 30:30), fifteen seconds (between 29:45 and 30:15), one second (between 29:59 and 30:01), 2 minutes (between 28:00 and 32:00), and so on.

Just be sure to include a flag with the record of each call that indicates whether the reminder has been shown yet.  This will ensure that your reminder is only shown once.


Scrappy
0
 
ZifNabCommented:
why not just using the event timer in RxLib?
0
 
viktornetCommented:
Hello Zif ;->

What's up? You seem to be back :-)

How was the big vacation you took?

Regards,
Viktor Ivanov
0
 
mykylAuthor Commented:
Ive seen the event timer but cant figure it out.
0
 
ZifNabCommented:
Hi all,

I'm back from Spain. But still have a week vacation... The vacation was great! I needed it.

Speak you soon.

Zif.
0
 
viktornetCommented:
I'm happy you liked it :-)

Talk to you later!

//Vik
0
 
ThaddyCommented:
Why not create a timer for everyone of the callers like

Type
   TTimerAndInfo=class(TTimer)
   private
     Fcaller:String;
     FPhone:string;
   public
     constriuctor create(Aonwer:Tcomponent);override;
     procedure Displaymessage(sender:Tobject);
   published
     property Caller:string read Fstring write Fstring;
     property Phone:string read FPhone write Fphone;
   end;
//Finish this yourself, don't forget to connect the
//displaymessage to the Ontimer event.
//

 Now, when you have a caller, Do something like this:
  with TTimerandInfo.Create(Form1) do
    begin
      Timeout:=30*1024;
      Caller:='John Doe';
      Phone:='999';
   end;
You don't have to worry about freeing the timer, because the form will do that for you, unless you manually free it after you handled the response to the call

0
 
viktornetCommented:
If you don't free the timer the system will run out of resources if you keep createing timers....

//Vik
0
 
TimYatesCommented:
Hurrah!!! Vanishing Icons...

Tim.
0
 
ThaddyCommented:
Try calculating how many calls you can answer in a day...
Vanishing icons won't be due to a couple of timers luring around in your system:)
(I just tried 200 of them simultaneously just to see what happened, silly me)
0
 
viktornetCommented:
You might be able to do that but is not a good way of programming :-|

//Vik
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 7
  • 2
  • 2
  • +5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now