Solved

Delay in Borland c++ for windows

Posted on 1998-03-17
6
521 Views
Last Modified: 2008-02-01
How can i do a delay on a windows platform in Bcw?
in c++ i used delay, but it doesnt work in windows platform.

and there is another problem with my c++ for windows.
I just got it a few days, and for some reason whenever I try to run a project, from the example or another place, it makes it and then it says: could not create process

?! whats wrong ?!
thanx.. Yoli
0
Comment
Question by:yolis
  • 4
6 Comments
 
LVL 22

Expert Comment

by:nietod
ID: 1183566
If by delay you mean suspend execution of your program, you can use the Sleep() windiows API function.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1183567
You specify a parameter to sleep that indicates how long you want to suspend execution in milliseconds.  Specify Sleep(500) to suspend for 1/2 second.  Sleep(1000) to suspend for a second, etc.

Can you provide more details about your make error?
0
 

Author Comment

by:yolis
ID: 1183568
thanx for the answer about the delay!
about my make problem, the problem with it that it doesnt give mt anymore details.
all that it says once it finshed making it, is: could not create process, even that the make was succesful...

0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 22

Expert Comment

by:nietod
ID: 1183569
Since it is new you can call Borland's instalation support and tell themn you think it is not installed correctly.
0
 

Accepted Solution

by:
Ant031898 earned 50 total points
ID: 1183570
Is is not a good idea to have delays in Windows code, but if you have to do it, this is one way:
you can write a function called delay:

void Delay(int delay){  //delay = time in seconds
 long time = GetTickCount();
 MSG msg;
 int quit = 0;
 while (!quit){
    if (GetMessage(&msg, HWindow, 0, 0)) {
      long timemsg = msg.time;
      TranslateMessage(&msg);
      DispatchMessage(&msg);
      if ( (timemsg - time) >= (1000*dealy) )
          quit=1;
   }
 }
}
0
 
LVL 22

Expert Comment

by:nietod
ID: 1183571
Except that does not hold up execution of a program.  (It prevents a section of code from continuing, but not the entire program.)  If you need to stop the execution of the program for a while, waiting for a hardware device, say.  That won't work as your program will still get and process messages.  The sleep function will suspend the execution of your program, but allow other programs to continue.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

707 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now