Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1CLOSEFILE("Scores.txt") | ACLOSEFILE is missing after writing. The file is still open in WRITE mode, so it cannot be opened for READ and the data may not be saved. Add CLOSEFILE("Scores.txt") before the second OPENFILE. | |
| 2OPENFILE "Scores.txt" FOR WRITE CLOSEFILE("Scores.txt") OPENFILE "Scores.txt" FOR READ | BThe file is closed after WRITE so it can then be opened in READ mode | |
| 3Every OPENFILE needs its own matching CLOSEFILE, so two open files need two CLOSEFILE statements | CWRITEFILE("Names.txt", Name) CLOSEFILE("Names.txt") OPENFILE "Names.txt" FOR READ | |
| 4A file is open in only one mode at a time, so close it after writing before reading the data back | DOnly one CLOSEFILE is used for two OPENFILE statements. A.txt is never closed. Add CLOSEFILE("A.txt") so there is one CLOSEFILE for each OPENFILE. | |
| 5OPENFILE "Scores.txt" FOR WRITE WRITEFILE("Scores.txt", Score) OPENFILE "Scores.txt" FOR READ | ECloses the open file so its data is safely saved and it is free to be opened again in a different mode | |
| 6OPENFILE "A.txt" FOR READ OPENFILE "B.txt" FOR WRITE CLOSEFILE("B.txt") | FOPENFILE "In.txt" FOR READ OPENFILE "Out.txt" FOR WRITE CLOSEFILE("In.txt") CLOSEFILE("Out.txt") |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
CLOSEFILE — Closes an open file so its data is safely saved and the file can be opened again in a different mode, such as READ after WRITE. Use one CLOSEFILE for each OPENFILE.OPENFILE "Scores.txt" FOR WRITE
WRITEFILE "Scores.txt", Score
CLOSEFILE "Scores.txt"CLOSEFILE "Scores.txt"
OPENFILE "Scores.txt" FOR READ
READFILE "Scores.txt", ScoreOPENFILE "Names.txt" FOR WRITE
WRITEFILE "Names.txt", Name
CLOSEFILE "Names.txt"OPENFILE "Log.txt" FOR WRITE
WRITEFILE "Log.txt", Entry
CLOSEFILE "Log.txt"OPENFILE "Scores.txt" FOR READ
READFILE "Scores.txt", Score
CLOSEFILE "Scores.txt"