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
共有
共有
共有
Dprice7
さんの投稿です
Y10
Computing
コンテンツの編集
印刷
埋め込み
もっと見る
割り当て
リーダーボード
もっと表示する
表示を少なくする
このリーダーボードは現在非公開です。公開するには
共有
をクリックしてください。
このリーダーボードは、リソースの所有者によって無効にされています。
このリーダーボードは、あなたのオプションがリソースオーナーと異なるため、無効になっています。
オプションを元に戻す
文を完成させる
は自由形式のテンプレートです。リーダーボード用のスコアは生成されません。
ログインが必要です
表示スタイル
フォント
サブスクリプションが必要です
オプション
テンプレートを切り替える
すべてを表示
アクティビティを再生すると、より多くのフォーマットが表示されます。
オープン結果
リンクをコピー
QRコード
削除
自動保存:
を復元しますか?