Using io

Previous: Using the Flusspferd shell / interpreter

There is an I/O function that you have probably already encountered: print.

> print("OK: ", [1,2,3,4])
OK: 1 2 3 4
> require("system").stdout.print("Same.")
Same.

In fact, print is a short form for the latter syntax. However, the print abbreviation is not available in modules. To spare you the hassle of typing require("system").stdout.print every time, you can assign the module to a variable.

const sys = require("system");
sys.stdout.print("Works!");

The other global function that is exposed as part of prelude.js is readLine - which reads a line from standard input.

> readLine().substr(1)
abcd
bcd

(Where abcd is input.)

Again, readLine is just an alias for require("system").stdin.readLine.

The system module exposes three streams by default:

There are many more things that you can do with this and the 'io' module, see the documentation for io.

Next: Using Getopt


Contact us at team -AT- flusspferd -DOT- org or as described on our homepage.

Generated on Thu Feb 4 23:05:12 2010 for Flusspferd by doxygen 1.6.1