blob: 354bdf60f59d0d7635c5d6b4b67b026d88a5aab4 (
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
discard """
input: "Arne"
output: '''
Hello! What is your name?
Nice name: Arne
fs is: nil
threw exception
'''
nimout: '''
I
AM
GROOT
'''
disabled: "windows"
"""
import streams
block tstreams:
var outp = newFileStream(stdout)
var inp = newFileStream(stdin)
writeLine(outp, "Hello! What is your name?")
var line = readLine(inp)
writeLine(outp, "Nice name: " & line)
block tstreams2:
var
fs = newFileStream("amissingfile.txt")
line = ""
echo "fs is: ",repr(fs)
if not isNil(fs):
while fs.readLine(line):
echo line
fs.close()
block tstreams3:
try:
var fs = openFileStream("shouldneverexist.txt")
except IoError:
echo "threw exception"
static:
var s = newStringStream("I\nAM\nGROOT")
for line in s.lines:
echo line
s.close
|