I/O

62 views
Skip to first unread message

Rogor

unread,
Oct 26, 2012, 6:34:09 PM10/26/12
to clay-l...@googlegroups.com
Hi there.
Where can i find info / doc about input - output? For example to manage command line input or to read - write in a file.
Thank ou

Joe Groff

unread,
Oct 27, 2012, 12:42:48 PM10/27/12
to clay-l...@googlegroups.com
Hi Rogor. There isn't much library documentation—your best bet is to
dive into the source code and see how things are done, especially by
looking at the test programs under the test/ directory. Command-line
arguments are handled similar to C—declare your "main" function as
taking a "args" parameter, and it will receive an array of argument
values equivalent to the argc/argv pair in C. The following program,
for example, will print each argument to stdout:

```
import printer.(println);
main(args) {
for (arg in args)
println(arg);
}
```

The `printer` module implements a generic printing facility;
`println(..objects);` prints one or more objects to stdout followed by
a newline, and `print(..objects)` does the same without the newline.
`printlnTo(stream, ..objects)` and `printTo(stream, ..object)` print
to a stream object, such as a file. The `io.files` module provides
File objects for opening and reading/writing files at a lower level.
Hopefully that will get you started. If you have any more questions,
don't be afraid to ask.

-Joe

Rogor

unread,
Oct 27, 2012, 8:04:30 PM10/27/12
to clay-l...@googlegroups.com
Interesting.... i hope this project has a long life.... c.u. soon for the next questions. Thanks
Reply all
Reply to author
Forward
0 new messages