Programs process and use ____. When the program finishes, or is closed, any data it held is lost. To prevent loss, data can be stored in a ____ so that it can be accessed again at a later date. Files have two modes of operation: 1. ____, where the file is opened so that data can be read from it. 2. Write, where the file is opened so that data can be ____ to it. Each item of data written to or from a file is called a record. Files have ____ modes of operation - read from and write to. Opening and closing files A file must be ____ before a record can be read from or written to it. To open a file, it must be referred to by its ____ (name), for example: file = openRead("scores.txt") This would open the ____ scores.txt and allow its contents to be ____ file = openWrite("scores.txt") This would open the file scores.txt and allow it to have data ____ to it. file.close() This would ____ the file. Reading from a file Once a file has been opened, the records are read from it one line at a time. The data held in this record can be ____ into a variable, or, more commonly, an ____ (list), for example: file = openRead("scores.txt") score = myFile.readLine() file.____ An array example is shown below: ____ = openWrite("scores.txt") for x = 0 to 9 scores____ = myFile.readLine() ____ file.close() End of file When reading a file that has more than one record, the computer needs to know what to do when there are no more records to ____. The endOfFile() statement checks to see if the ____ record has already been read, for example: ____ = openRead("scores.txt") while NOT file.endOfFile() scores____ = myFile.readLine() x = x + 1 endwhile file.____ The above code would read each record and place it into an ____ called scores. The operations ____ when there are no more files to read. Arrays are often used to hold data read from files.
0%
2.2 Basic File Handling Operations
Delen
Delen
Delen
door
Dprice7
Y10
Computing
Inhoud Bewerken
Afdrukken
Embedden
Meer
Toewijzingen
Scorebord
Meer weergeven
Minder weergeven
Dit scoreboard is momenteel privé. Klik op
Delen
om het publiek te maken.
Dit scoreboard is uitgeschakeld door de eigenaar.
Dit scoreboard is uitgeschakeld omdat uw opties anders zijn dan die van de eigenaar.
Opties Herstellen
Maak de zin af
is een open template. Het genereert geen scores voor een scoreboard.
Inloggen vereist
Visuele stijl
Lettertypen
Abonnement vereist
Opties
Template wisselen
Alles weergeven
Er zullen meer templates verschijnen terwijl je de activiteit gebruikt.
Open resultaten
Kopieer link
QR-code
Verwijderen
Automatisch opgeslagen activiteit "
" herstellen?