summaryrefslogtreecommitdiff
path: root/tests/general/scan.icn
blob: 2dfda41f5ef266b30787890008c59660480277a6 (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
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
record array(a,b,c,d,e,f,g)

procedure p1()
   write(" ----> ",image() | "none")
   write("every write((\"badc\" | \"edgf\" | \"x\") ? write(upto(!&lcase))) ----> ",image(every write(("badc" | "edgf" | "x") ? write(upto(!&lcase)))) | "none")
   write("every write(((\"aeiou\" | \"foobaz\") ? upto('dracula')) ? =(1 to 10)) ----> ",image(every write((("aeiou" | "foobaz") ? upto('dracula')) ? =(1 to 10))) | "none")
   write("every write((1 to 10) ? move(1)) ----> ",image(every write((1 to 10) ? move(1))) | "none")
   write("&subject := &pos ----> ",image(&subject := &pos) | "none")
   write("&pos :=: &subject ----> ",image(&pos :=: &subject) | "none")
   write("&pos ----> ",image(&pos) | "none")
   write("&subject ----> ",image(&subject) | "none")
   write("+1 ----> ",image(+1) | "none")
   write("-1 ----> ",image(-1) | "none")
end

procedure p2()
   write("?10 ----> ",image(?10) | "none")
   write("?10 ----> ",image(?10) | "none")
   write("?10 ----> ",image(?10) | "none")
   write("~&cset ----> ",image(~&cset) | "none")
   write("~&ascii ----> ",image(~&ascii) | "none")
   write("&subject := string(&lcase) ----> ",image(&subject := string(&lcase)) | "none")
   write("=\"a\" ----> ",image(="a") | "none")
   write("=\"b\" ----> ",image(="b") | "none")
   write("=\"d\" ----> ",image(="d") | "none")
   write("&subject := string(&lcase) ----> ",image(&subject := string(&lcase)) | "none")
end

procedure p3()
   write("while write(move(1)) ----> ",image(while write(move(1))) | "none")
   write("&subject := string(&lcase) ----> ",image(&subject := string(&lcase)) | "none")
   write("every write(tab(1 to 10)) ----> ",image(every write(tab(1 to 10))) | "none")
   write("pos(0) ----> ",image(pos(0)) | "none")
   write("pos(15) ----> ",image(pos(15)) | "none")
   write("&subject := string(&lcase) ----> ",image(&subject := string(&lcase)) | "none")
   write("pos(1) ----> ",image(pos(1)) | "none")
   write("every write(\"abcdef\" ? tab(1 to 10)) ----> ",image(every write("abcdef" ? tab(1 to 10))) | "none")
   write("every write(\"abcde\" ? while move(2) ? move(1)) ----> ",image(every write("abcde" ? while move(2) ? move(1))) | "none")
   write("s := \"abcdef\" ----> ",image(s := "abcdef") | "none")
   write("s ?:= move(3) ----> ",image(s ?:= move(3)) | "none")
end

procedure p4()
   write("s := \"abcdef\" ----> ",image(s := "abcdef") | "none")
   write("every write(s ?:= upto(&lcase)) ----> ",image(every write(s ?:= upto(&lcase))) | "none")
   write("s := \"this is the time to work it all out\" ----> ",image(s := "this is the time to work it all out") | "none")
   write("every write(s ? tab(find(\" \"))) ----> ",image(every write(s ? tab(find(" ")))) | "none")
   write("s := \"xxxxxx\" ----> ",image(s := "xxxxxx") | "none")
   write("every s ? write(=(\"a\" | \"x\")) ----> ",image(every s ? write(=("a" | "x"))) | "none")
   write("\"abcdef\" ? (tab(0) & (while write(move(-1)))) ----> ",image("abcdef" ? (tab(0) & (while write(move(-1))))) | "none")
end

procedure main()
   p1()
   p2()
   p3()
   p4()
end