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 | |
|---|---|---|
| 1OPENFILE FileB.txt FOR WRITE | AReads one line from FileA.txt and stores it in the variable LineOfText, which carries the line to the other file | |
| 2READFILE FileA.txt, LineOfText | BFileA.txt is opened for WRITE but then read from. A file you read from must be opened FOR READ, and WRITE would also replace its data. | |
| 3The copied line is written into the second file using the same variable that READFILE filled | CWRITEFILE FileB.txt, LineOfText | |
| 4Each file that was opened must be closed once the copying is finished, so both files need a CLOSEFILE | DCLOSEFILE FileA.txt CLOSEFILE FileB.txt | |
| 5OPENFILE FileA.txt FOR WRITE READFILE FileA.txt, LineOfText | EOpens the second file in WRITE mode so the program can put the copied line into it, while FileA.txt is already open for READ | |
| 6READFILE FileA.txt, LineOfText WRITEFILE FileB.txt, LineOfText CLOSEFILE FileA.txt | FFileB.txt is never closed. Both files need CLOSEFILE, so CLOSEFILE FileB.txt is missing. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
WRITEFILE FileB.txt, LineOfText — Writes the line held in LineOfText (read earlier from FileA.txt) into FileB.txt, copying it between files. Both files must be opened first and each one closed after.OPENFILE FileA.txt FOR READ
OPENFILE FileB.txt FOR WRITEREADFILE FileA.txt, LineOfText
WRITEFILE FileB.txt, LineOfTextREADFILE FileA.txt, LineOfText
WRITEFILE FileB.txt, LineOfTextWRITEFILE FileB.txt, LineOfText
CLOSEFILE FileA.txt
CLOSEFILE FileB.txtOPENFILE FileB.txt FOR WRITE
WRITEFILE FileB.txt, LineOfText