Skip to content

Commit 0ce42f7

Browse files
committed
Add the FILE IO instructions to the input and improve it
1 parent acfc739 commit 0ce42f7

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

full-input.txt

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,19 +79,24 @@ print(names[3])
7979
Array board[8,8]
8080
board[0,0]="rook"
8181

82-
// File IO not done
83-
myFile = openRead("sample.txt")
82+
// File IO
83+
myFile = openRead("sample-read.txt")
8484
x = myFile.readLine()
8585
myFile.close()
86+
print("First line below")
87+
print(x)
88+
print()
8689

87-
myFile = openRead("sample.txt")
90+
myFile = openRead("sample-read.txt")
8891
while NOT myFile.endOfFile()
8992
print(myFile.readLine())
9093
endwhile
9194
myFile.close()
95+
print()
96+
print()
9297

93-
myFile = openWrite("sample.txt")
94-
myFile.writeLine("Hello World")
98+
myFile = openWrite("sample-write.txt")
99+
myFile.writeLine("THIS IS A SAMPLE TEXT FILE CREATED TO SHOW THE WRITE FUNCTIONALITY")
95100
myFile.close()
96101

97102
print("Hello World") //This is a comment

input.txt

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,24 @@ switch something:
102102
print("#Douglas Adams")
103103
default:
104104
print("You are a slave to the system")
105-
endswitch
105+
endswitch
106+
107+
// File IO
108+
myFile = openRead("sample-read.txt")
109+
x = myFile.readLine()
110+
myFile.close()
111+
print("First line below")
112+
print(x)
113+
print()
114+
115+
myFile = openRead("sample-read.txt")
116+
while NOT myFile.endOfFile()
117+
print(myFile.readLine())
118+
endwhile
119+
myFile.close()
120+
print()
121+
print()
122+
123+
myFile = openWrite("sample-write.txt")
124+
myFile.writeLine("THIS IS A SAMPLE TEXT FILE CREATED TO SHOW THE WRITE FUNCTIONALITY")
125+
myFile.close()

0 commit comments

Comments
 (0)