473,382 Members | 1,377 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Wait, pause, sleep, w/e

Im in the video club at my school, and for a presentation were making,
we need some computer scenes.

Each of the characters has an ID wich i have used as an IF function so
typing the right id # goes to the specified character. For the next
part, i have a bunch of text that makes little sene but sounds
"computery" to a non comupter literate person. Basically connecting,
database, and mainframe thrown around, if u can understand that.
For the connecting part, i would like to make the word connecting
appear ( using cout<<"connecting\n"; ) For the next part, . . . how
do i make the periods come onto the screen once every say, 2 seconds so
it looks like its actually loading something.
Rember, this isnt a purposeful program, its intended to look computery,
and thats about all

thanks for any help,,, ~3than

Dec 19 '06 #1
4 2636

"3than7" <el*****@gmail.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
Im in the video club at my school, and for a presentation were making,
we need some computer scenes.

Each of the characters has an ID wich i have used as an IF function so
typing the right id # goes to the specified character. For the next
part, i have a bunch of text that makes little sene but sounds
"computery" to a non comupter literate person. Basically connecting,
database, and mainframe thrown around, if u can understand that.
For the connecting part, i would like to make the word connecting
appear ( using cout<<"connecting\n"; ) For the next part, . . . how
do i make the periods come onto the screen once every say, 2 seconds so
it looks like its actually loading something.
Rember, this isnt a purposeful program, its intended to look computery,
and thats about all

thanks for any help,,, ~3than

#include <ios>
#include <iostream>
#include <ctime>
#include <string>

void status (const std::string text,
unsigned int duration,
unsigned int interval)
{
std::cout << text;
std::time_t last;
std::time_t begin(std::time(0));

while(std::difftime(last = std::time(0), begin) < duration)
{
while(std::difftime(std::time(0), last) < interval)
; /* empty statement */

std::cout << '.' << std::flush;
}
}

int main()
{
status("connecting", 10, 2);
std::cout << " Done.\n";
return 0;
}
-Mike
Dec 19 '06 #2

Mike Wahler wrote:
"3than7" <el*****@gmail.comwrote in message
news:11**********************@l12g2000cwl.googlegr oups.com...
Im in the video club at my school, and for a presentation were making,
we need some computer scenes.

Each of the characters has an ID wich i have used as an IF function so
typing the right id # goes to the specified character. For the next
part, i have a bunch of text that makes little sene but sounds
"computery" to a non comupter literate person. Basically connecting,
database, and mainframe thrown around, if u can understand that.
For the connecting part, i would like to make the word connecting
appear ( using cout<<"connecting\n"; ) For the next part, . . . how
do i make the periods come onto the screen once every say, 2 seconds so
it looks like its actually loading something.
Rember, this isnt a purposeful program, its intended to look computery,
and thats about all

thanks for any help,,, ~3than


#include <ios>
#include <iostream>
#include <ctime>
#include <string>

void status (const std::string text,
unsigned int duration,
unsigned int interval)
{
std::cout << text;
std::time_t last;
std::time_t begin(std::time(0));

while(std::difftime(last = std::time(0), begin) < duration)
{
while(std::difftime(std::time(0), last) < interval)
; /* empty statement */

std::cout << '.' << std::flush;
}
}

int main()
{
status("connecting", 10, 2);
std::cout << " Done.\n";
return 0;
}
-Mike

Thank you very much, but is this the simpilist way to do this, because
i'd like to be able to use this feature elsewhere, and im not sure
exactly what you did there. Thanks ALOT thou, very helpfull.

Dec 19 '06 #3
3than7 wrote:
Mike Wahler wrote:
>"3than7" <el*****@gmail.comwrote in message
news:11**********************@l12g2000cwl.googleg roups.com...
>>Im in the video club at my school, and for a presentation were making,
we need some computer scenes.

Each of the characters has an ID wich i have used as an IF function so
typing the right id # goes to the specified character. For the next
part, i have a bunch of text that makes little sene but sounds
"computery" to a non comupter literate person. Basically connecting,
database, and mainframe thrown around, if u can understand that.
For the connecting part, i would like to make the word connecting
appear ( using cout<<"connecting\n"; ) For the next part, . . . how
do i make the periods come onto the screen once every say, 2 seconds so
it looks like its actually loading something.
Rember, this isnt a purposeful program, its intended to look computery,
and thats about all

thanks for any help,,, ~3than

#include <ios>
#include <iostream>
#include <ctime>
#include <string>

void status (const std::string text,
unsigned int duration,
unsigned int interval)
{
std::cout << text;
std::time_t last;
std::time_t begin(std::time(0));

while(std::difftime(last = std::time(0), begin) < duration)
{
while(std::difftime(std::time(0), last) < interval)
; /* empty statement */

std::cout << '.' << std::flush;
}
}

int main()
{
status("connecting", 10, 2);
std::cout << " Done.\n";
return 0;
}
-Mike


Thank you very much, but is this the simpilist way to do this, because
i'd like to be able to use this feature elsewhere, and im not sure
exactly what you did there. Thanks ALOT thou, very helpfull.
There are other options depending on your platform. POSIX systems have a
"sleep" function, for example. The advantage of Mike Wahler's approach
is that it is all standard C++, so it should work anywhere that has a
C++ compiler.

--
Alan Johnson
Dec 19 '06 #4

yes, i played around with it and figured out how to make it work for my
purposes
thanks a bunch mike!

Dec 19 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Jurgen Oerlemans | last post by:
I have a code where I perform several actions on files. Between these actions I want to wait for 1 second. Or 2 seconds. How can I easily do this without using a timer? Jurgen
8
by: Wim | last post by:
My GUI application starts a process (a console program) when the user hits Play. I would like to add an option to pause that process. The code I've added to detect if the user hit pause/unpause...
15
by: Snuyt | last post by:
Hello, I want the program to wait a few seconds between executing code. It should look something like this: public sub xx() ...code... wait(2) 'wait 2 seconds ...code...
18
by: Coder | last post by:
Howdy everybody! How do I do the following... while (myVary != true){}; Obviously I do not want to use 100% of the processor to stay in this infinite loop till myVar == true. But wait do I...
4
by: SheldonMopes | last post by:
Is there a way to force Access to pause execution for a specified period of time ? I would like a command button on a form to run it's code when clicked and then pause for 2 seconds before allowing...
12
by: Perecli Manole | last post by:
I am having some strange thread synchronization problems that require me to better understand the intricacies of Monitor.Wait/Pulse. I have 3 threads. Thread 1 does a Monitor.Wait in a SyncLock...
6
by: Alan T | last post by:
How do I tell my application to wait for 2 seconds?
6
by: Peted | last post by:
Hi wondering what is the best way to do this Need a user to click a button, that sends 3 or 4 string based commands via a TCP/ip socket link I can connect to the ip device no problems, am...
19
by: dave.zoltan | last post by:
Hi everybody, I am awfully new to programming in C and all I have had to work with so far have been tutorials that I've found online. In my searching, however, I have not found a solution to a...
5
harshadd
by: harshadd | last post by:
How do i make an execution of program wait for n seconds? where n could be any Integer.. is there Sleep or pause or wait like command in VB6?
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.