aboutsummaryrefslogtreecommitdiff
path: root/tests/i/text-files/program.cps
blob: 42632fdafb58eb86d534b868f24f5cf9ace4007b (plain)
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

DECLARE Line : STRING
DECLARE Count : INTEGER
OPENFILE "input.txt" FOR READ
Count <- 0
WHILE NOT EOF("input.txt")
    READFILE "input.txt", Line
    OUTPUT "[", Line, "]"
    Count <- Count + 1
ENDWHILE
CLOSEFILE "input.txt"
OPENFILE "empty.txt" FOR READ
OUTPUT EOF("empty.txt"), ":", Count
CLOSEFILE "empty.txt"
OPENFILE "result.txt" FOR WRITE
WRITEFILE "result.txt", "first"
WRITEFILE "result.txt", ""
CLOSEFILE "result.txt"
OPENFILE "result.txt" FOR APPEND
WRITEFILE "result.txt", "last"
CLOSEFILE "result.txt"
OPENFILE "result.txt" FOR READ
WHILE NOT EOF("result.txt")
    READFILE "result.txt", Line
    OUTPUT "[", Line, "]"
ENDWHILE
CLOSEFILE "result.txt"