xtd 0.2.0
Loading...
Searching...
No Matches

◆ beep() [1/2]

static void xtd::console::beep ( )
static

Plays the sound of a beep through the console speaker.

Remarks
By default, the beep plays at a frequency of 800 hertz for a duration of 200 milliseconds
Examples
The following example demonstrates the beep method. The example accepts a number from 1 through 9 as a command line argument, and plays the beep that number of times.
#include <xtd/threading/thread>
#include <xtd/console>
#include <xtd/int32_object>
using namespace xtd;
using namespace xtd::threading;
auto main(int argc, char* argv[]) -> int {
auto x = 0;
//
if ((argc == 2) && (int32_object::try_parse(argv[1], x) == true) && ((x >= 1) && (x <= 9))) {
for (auto i = 1; i <= x; ++i) {
console::write_line("Beep number {}.", i);
thread::sleep(100_ms);
}
} else
console::write_line("Usage: Enter the number of times (between 1 and 9) to beep.");
}
// This code produces the following output if 3 is entered on command line:
//
// Beep number 1.
// Beep number 2.
// Beep number 3.
static bool try_parse(const xtd::string &value, type_t &result) noexcept
Converts the string to its type_t equivalent. A return value indicates whether the conversion succeed...
Definition box.h:133
static void beep()
Plays the sound of a beep through the console speaker.
static void write_line()
Writes the current line terminator to the standard output stream using the specified format informati...
@ i
The I key.
@ x
The X key.
The xtd::threading namespace provides classes and interfaces that enable multithreaded programming....
Definition abandoned_mutex_exception.h:10
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.h:10