Solved

How to make an app wait...

Posted on 1998-04-23
6
143 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

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

Suggested Solutions

Title # Comments Views Activity
Convert GUI app into console app for Win32 Env 5 125
Working with hours 3 74
Tembedded WB animatid gifs not animated on some pcs 2 86
Multi-layered image in FireMonkey 9 67
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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