Solved

How to make an app wait...

Posted on 1998-04-23
6
145 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
[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
  • 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
Technology Partners: 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 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

Industry Leaders: 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!

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
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…

688 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