Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using the timer

Posted on 1998-09-26
16
Medium Priority
?
160 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

618 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