?
Solved

Using the timer

Posted on 1998-09-26
16
Medium Priority
?
158 Views
Last Modified: 2010-04-06
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
Comment
Question by:mykyl
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 2
  • 2
  • +5
16 Comments
 
LVL 2

Expert Comment

by:rene100
ID: 1340887
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1340888
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1340889
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 20

Expert Comment

by:Madshi
ID: 1340890
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1340891
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
 
LVL 5

Expert Comment

by:scrapdog
ID: 1340892
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
 
LVL 8

Expert Comment

by:ZifNab
ID: 1340893
why not just using the event timer in RxLib?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1340894
Hello Zif ;->

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

How was the big vacation you took?

Regards,
Viktor Ivanov
0
 

Author Comment

by:mykyl
ID: 1340895
Ive seen the event timer but cant figure it out.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1340896
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1340897
I'm happy you liked it :-)

Talk to you later!

//Vik
0
 
LVL 2

Accepted Solution

by:
Thaddy earned 300 total points
ID: 1340898
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1340899
If you don't free the timer the system will run out of resources if you keep createing timers....

//Vik
0
 
LVL 35

Expert Comment

by:TimYates
ID: 1340900
Hurrah!!! Vanishing Icons...

Tim.
0
 
LVL 2

Expert Comment

by:Thaddy
ID: 1340901
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
 
LVL 10

Expert Comment

by:viktornet
ID: 1340902
You might be able to do that but is not a good way of programming :-|

//Vik
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses
Course of the Month12 days, 4 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question