summary refs log tree commit diff stats
path: root/tests/hallo.nim
blob: 07063379366bd26da42b2c67ad24e58e41223f53 (plain) (blame)
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
# Hallo world program

echo("Hi! What's your name?")
var name = readLine(stdin)

if name == "Andreas":
  echo("What a nice name!")
elif name == "":
  echo("Don't you have a name?")
else:
  echo("Your name is not Andreas...")

for i in 0..name.len-1:
  if name[i] == 'm':
    echo("hey, there is an *m* in your name!")

echo("Please give your password: (12345)")
var pw = readLine(stdin)

while pw != "12345":
  echo("Wrong password! Next try: ")
  pw = readLine(stdin)

echo("""Login complete!
What do you want to do?
delete-everything
restart-computer
go-for-a-walk""")

case readline(stdin)
of "delete-everything", "restart-computer":
  echo("permission denied")
of "go-for-a-walk":     echo("please yourself")
else:                   echo("unknown command")