[wiki:TutSimpleIOComments Leave Comments, Critiques, and Suggestions Here] = Simple Input/Output with Tango = Input, as well as output, are essential parts of almost every program. Tango provides a wide set of tools for a wide set of issues. This tutorial refers to the usage of the Tango package `tango.io` (See [source:trunk/tango/io]). If you're unfamiliar with conduits and other IO principles, please see [wiki:ChapterIO the Chapter about IO in the Tango Reference Manual] == Console I/O == While most programs may be graphical these days, console programs are still important... === Console Output === The simple way to do console output is via the `Console` package. In order to use it, import `tango.io.Console`. This allows one to write a string directly to the standard output device, which is usually the console. The following is a minimal `Hello World!` program in Tango: {{{ #!d import tango.io.Console; void main() { Cout("Hello, World").newline; } }}} Note that the newline was needed not only to write a new line to the console, but also to flush the buffer. Without the newline nothing would have printed (though you could have used `flush` instead of `newline`). `Cout()` returns an instance of `Cout`, so you can chain arguments together thus: {{{ #!d Cout("Hello")(" ")("World").newline; }}} ('''n.b.''' without a following set of parenthesis, `newline` ends the chaining process. This is an artifact of the compiler, rather than of Cout itself) '''The Standard Error Stream:''' Note that there is a process analogous to `Cout` called `Cerr`. Use it in the same way. Do '''not''' expect it to be unbuffered. === Console Input === The next simplest program asks the user for some information. This is a "What's your name?" program: {{{ #!d import tango.io.Console; void main() { char [] str; Cout("Hi There!").newline; Cout(" What's your name? ").flush; str = Cin.get(); Cout("Well, hello, ")(str).newline; } }}} The important thing here is the `Cin` object. In order to read a line into a string the `get()` method is used. == File I/O == There are several ways to talk to a file, or let a file talk to your program. If you are interested in using files for logging, please see [wiki:TutLogging the Logging Tutorial]. === Detailed File Information === === File Creation === === File Modification === === File Conduit === === Directories ===