Solved

How to make an app wait...

Posted on 1998-04-23
6
142 Views
Last Modified: 2010-04-06
Hi,
 The app I'm writing runs DVIPS (as you probably know it converts device independant files to postscript files) externally if the user clicks the relevant button. This is fine, but I want to display a messagebox saying whether the file was created successfully or not. I've written some code if FileExists ..... then .. etc. The problem is that I need the app to wait a few seconds before it checks whether the file has been created. Can anyone tell me how to do this?
A quick response would be much appreciated...
Cheers.
0
Comment
Question by:PiersBull
  • 4
  • 2
6 Comments
 
LVL 5

Accepted Solution

by:
inter earned 50 total points
ID: 1336639
Hi there,
For Delphi 2.0+ use API function
   ...
   Sleep(2000); //wait for 2 seconds
   ...
Regards, (if I interpret the problem wrong, please write down)
Igor
0
 

Author Comment

by:PiersBull
ID: 1336640
Hi inter,
   unfortunately I'm only on Delphi 1. Any ideas?
Cheers.
0
 
LVL 5

Expert Comment

by:inter
ID: 1336641
The basic solution I can found for Delphi 1.0 is  as follows:

1 - Declare a global var in your form as
var
  TimeOut : boolean;
2 - Put a timer on your form
3 - In FormCreate;
  Timer1.Enabled := false;
  TimeOut := false;
4 - Add the following procedure to your unit(form object)
procedure TForm1.Wait(Msec : integer);
begin
   Timer1.Interval := Msec;
   TimeOut := false;
   while not (TimeOut) and not (Application.Terminated) do
       Application.ProcessMessages;
end;
5 - in OnTimer event of Timer1
begin
  TimeOut := true;
  Timer1.Enabled := false;
end;
6 - Now you can call from any where as follows:
// do you operations
....
Wait(1000); //wait one second(approximate for Win16)
//check them
...

Regards,
Igor
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 5

Expert Comment

by:inter
ID: 1336642
Yeah I have found it:

Write and call this proc instead(in WinProcs)

procedure Wait(Msec : longint);
var
  b : longint;
begin
  b := GetTickCount;
  while (GetTickCount - b) < Msec do
     Application.ProcessMessages;
end;

regards
igor
0
 
LVL 5

Expert Comment

by:inter
ID: 1336643
I means GetTickCount is in WinProcs
0
 

Author Comment

by:PiersBull
ID: 1336644
Did the job nicely! Cheers Igor.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

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…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

806 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