Skip to content
Dennis Rönn edited this page Oct 4, 2022 · 1 revision

Dern currently only support terminal based input and output. The 3 keywords in use currently is print, write and read.

Examples

Output

For output, you have print and write.
Here's an example for print.

print("Hello, ");
print("World!");

This will give the following output.

Hello,
World!

Meanwhile if you replaced print with write in the first line, you'd get this output.

Hello, World!

The only difference between print and write is that print includes a new line at the end, while write does not.

Input

For input, you only have read, which may take 0 or 1 parameters, and return Text or Number depending on what the user typed in.

var name = read("What is your name? ");
print("Hello: " + name);

This will first run write("What is your name? "); then wait for user input.
Similarly you can omit the parameter if you want to control that yourself.
The following code has the exact same outcome.

write("What is your name? ");
var name = read();
print("Hello: " + name);

Please note currently there's no way to require an integer. The following code works, but will error out if the user enters a non-integer output (like Text input).

var age = read("What is your age? ");
if (age >= 18) {
    print("You can drive");
} else {
    print("You cannot drive");
}
Clone this wiki locally