I compile by pressing f9 inside the ide. Should I be setting the flags you used, the -l and -o ones? I honestly did not know Devc++ would let you compile using it from the cmd line, though it seems obvious now that you say it.
Have a great day, Alex
----- Original Message ----- From: "Ken Perry" <whistler@xxxxxxxxxxxxx To: <programmingblind@xxxxxxxxxxxxx Date sent: Sun, 8 Jun 2008 19:13:18 -0700 Subject: RE: Alex beep code example threads
Nod if you have the boost library installed on devc++ the command
line to
compile my example is
G++ -l boost_thread-mt beep.cpp -o beep
You will also need the boost_thread dll in the directory of your
executable
or registered on your machine.
Now if you look in your dev c++ include and you don't see the
boost
directory you might have to go get it. Unless of course they
install it in
its own directory but I doubt it. Its not hard to install but
its not easy
to find the install instructions so again if you have any
problems let me
know.
Also if you want me to send an exe of my example I will send it
to your
email but I will have to zip it up of course because my servers
spam filter
won't let me send exe files any more than get them. Ken
-----Original Message----- From: programmingblind-bounce@xxxxxxxxxxxxx[mailto:programmingblind-bounce@xxxxxxxxxxxxx] On Behalf Of Alex
Hall
Sent: Sunday, June 08, 2008 6:44 PM To: programmingblind@xxxxxxxxxxxxx Subject: re: Alex beep code example threads
Thanks for the example!! I will try it to find out if I have the
boost
libraries. I never knew there was a function to beep the sound
card, I will
look into that. I want this to work whether I have my speakers
on or not,
mainly for my dorm where my only speakers are headphones I am not
always
wearing. I can have them both beep, though... I will keep
tweeking it, as
well as put it onto my pc in my compiler so I can see just how it
works;
reading it in braille on my braillenote is not quite the same
thing. I
always thought braille would be easier for coding, but I am now
so used to
speech that using braille is often slower and more confusing.Anyway, thanks again and I will let you know if I do not have the
boost
library.
Have a great day, Alex
----- Original Message ----- From: "Ken Perry" <whistler@xxxxxxxxxxxxx To: <programmingblind@xxxxxxxxxxxxx Date sent: Sun, 8 Jun 2008 18:21:20 -0700 Subject: Alex beep code example threads
Alex I want to first say if I was doing this I would make sure tonot usejust beep and I would code in a call to the wave function so youcould use asound card. I guess if the person didn't have a sound card youcould checkfor it and then use the pc speaker. With that said I liked yourlittleproject and though I would show you how it would be done with theboostthread and date libraries. Now if you don't have boost installedI can tellyou how to do that if you want to. Here is the code that I madethough andit works.
#include "boost/date_time/posix_time/posix_time.hpp" #include <boost/thread.hpp #include <boost/bind.hpp #include <iostream #include <windows.h #include <string
using namespace boost::posix_time; using namespace boost::gregorian; using namespace std;
enum PERIOD { HOUR, QUARTER, HALF, THREEQUARTER, };
bool beeps = true;
void chime (PERIOD when) { int chimes = 0; // used to repeat chimes for theminuteslong LastChime;//used to not repeat when it has already chimed
//get
the current time from the clock -- one second resolution ptime
now =
second_clock::local_time ();
//set the start last_time so that it doesn't ring instantly if (when == HOUR) LastChime = now.time_of_day ().hours (); else LastChime = now.time_of_day ().minutes ();
while (1) { Sleep (1000); now = second_clock::local_time ();
if (beeps == true) { switch (when) { case HOUR: if (LastChime != now.time_of_day ().hours ()) { for (long i = 0; i < now.time_of_day ().hours ();i++){ Beep (244, 500); Sleep (500); } LastChime = now.time_of_day ().hours (); } break; case QUARTER: if ((LastChime != now.time_of_day ().minutes ()) && (now.time_of_day ().minutes () == 15)) chimes = 1; break; case HALF: if ((LastChime != now.time_of_day ().minutes ()) && (now.time_of_day ().minutes () == 30)) chimes = 2; break; case THREEQUARTER: if ((LastChime != now.time_of_day ().minutes ()) && (now.time_of_day ().minutes () == 45)) chimes = 3; break; }; //end switch
if (chimes > 0) { for (; chimes > 0; chimes--) { Beep (488, 500); Sleep (500); } LastChime = now.time_of_day ().minutes (); } } //end if beeps true } //end while
}
void input () { string cmd; while (1) { cin >> cmd;
if (cmd[0] == 'b') { beeps = true; cout << "Beeps turned on." << endl; } else if (cmd[0] == 's') { beeps = false; cout << "Beeps turned off." << endl; } else if (cmd[0] == 'q') { cout << "Turning off beeper." << endl; exit (0); }
} }
int main () { boost::thread_group Tg; Tg.create_thread (boost::bind (chime, HOUR)); Tg.create_thread (boost::bind (chime, QUARTER)); Tg.create_thread (boost::bind (chime, HALF)); Tg.create_thread (boost::bind (chime, THREEQUARTER)); Tg.create_thread (boost::bind (input));
Tg.join_all (); std::cout << "Done! =)" << std::endl; std::cin.get (); return 0; }
__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind
__________ View the list's information and change your settings at //www.freelists.org/list/programmingblind
__________View the list's information and change your settings at //www.freelists.org/list/programmingblind