-
Notifications
You must be signed in to change notification settings - Fork 0
/
full-input.txt
102 lines (81 loc) · 1.7 KB
/
full-input.txt
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
x=3
name="Bob"
str(3)
int("3")
float("3.14")
print("hello")
name=input("Please enter your name")
for i=0 to 7
print("Hello")
next i
while answer!="computer"
answer=input("What is the password?")
endwhile
do
answer=input("What is the password?")
until answer=="computer"
if entry=="a" then
print("You selected A")
elseif entry=="b" then
print("You selected B")
else
print("Unrecognised selection")
endif
switch entry:
case "A":
print("You selected A")
case "B":
print("You selected B")
default:
print("Unrecognised selection")
endswitch
someText="Computer Science"
print(someText.length)
print(someText.substring(3,3))
function triple(number)
return number*3
endfunction
y=triple(7)
procedure greeting(name)
print("hello"+name)
endprocedure
greeting("Hamish")
// Not done
procedure foobar(x:byVal, y:byRef)
...
...
endprocedure
// Logical operators
// Note: XOR is AB' + A'B, since I want to test AND, OR and NOT this works out
function xor(a, b)
return ((a AND NOT(b)) OR (NOT(a) AND b))
endfunction
print(xor(true, true))
array names[5]
names[0]="Ahmad"
names[1]="Ben"
names[2]="Catherine"
names[3]="Dana"
names[4]="Elijah"
print(names[3])
// Not done
Array board[8,8]
board[0,0]="rook"
// File IO
myFile = openRead("sample-read.txt")
x = myFile.readLine()
myFile.close()
print("First line below")
print(x)
print()
myFile = openRead("sample-read.txt")
while NOT myFile.endOfFile()
print(myFile.readLine())
endwhile
myFile.close()
print()
print()
myFile = openWrite("sample-write.txt")
myFile.writeLine("THIS IS A SAMPLE TEXT FILE CREATED TO SHOW THE WRITE FUNCTIONALITY")
myFile.close()
print("Hello World") //This is a comment