File: console.md

package info (click to toggle)
surgescript 0.5.4.4-1.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,876 kB
  • sloc: ansic: 13,674; makefile: 16
file content (69 lines) | stat: -rw-r--r-- 1,132 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
Console
=======

The Console is a mechanism that allows users to interact with your app via a text-based interface. You can print data to the user and read data from the user.

Functions
---------

#### print

`print(line)`

Prints a line to the console.

*Arguments*

* `line`: string. The message to be printed.

*Example*

```
// this will print "Hello, there!" and quit
object "Application"
{
    state "main"
    {
        Console.print("Hello, there!");
        Application.exit();
    }
}
```

#### write

`write(str)`

Writes a string to the console, without a line break at the end.

*Arguments*

* `str`: string. The string to be written.

#### readline

`readline()`

Reads a line from the standard input.

*Returns*

Returns the string just read, without a line break at the end.

*Example*

```
// will ask the name of the user until a name is given
object "Application"
{
    state "main"
    {
        Console.print("Hey pal, what's your name? ");
        name = Console.readline();
        if(name != "") {
            Console.print("Nice to meet you, " + name);
            Application.exit();
        }
    }
}
```