prompt.anubis
961 Bytes
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
read bool.anubis
*** (14) Prompting and reading from standard input.
*** (14.1) Reading a line from the standard input.
public define String
read_line_from_stdin
(
List(Word8) so_far
) =
if *stdin is
{
failure then implode(reverse(so_far)),
success(c) then
//println("read line read char ["+c+"|"+implode([c])+"]");
if c = '\n' | c='\r' then
implode(reverse(so_far))
else
print(implode[c]);
read_line_from_stdin([c . so_far])
}.
*** (14.2) Printing a prompt and reading the answer.
public define String
prompt
(
String header
) =
print(header);
read_line_from_stdin([]).
*** (14.3) The same one for a password:
public define String
prompt_for_password
(
String header
) =
print(header);
get_password. // see 'predefined.anubis'