02 Section 5 - File Handling and Storing Data Flashcards
What is the first thing you have to do when dealing with file handling?
Open the external file using an open command and assigning it to a variable
What is an open command in Read mode?
newFile = openRead(“newfile.txt”)
-sometimes you have to give the whole file path, not just the file name
What is an open command in Write mode?
newFile = openWrite(“newfile.txt”)
-sometimes you have to give the whole file path, not just the file name
What are the two modes you can open files in?
Read
Write
What is read mode for opening a file?
It allows you to read data from the external file into your program
What is write mode for opening a file?
It allows you to write data from your program to an external file
When a file is opened where does it start reading or writing from?
The beginning of the file
-as you read from or write to the file, the program keeps its place in the file
What is the last thing you should do when dealing with file handling?
You should close the file
-if you forget to close it then a file can remain locked and prevent others from editing it
What is the close command for file handling?
newFile.close()
How can you write to a file once it is opened?
newFile.writeLine()
-if the file already contains some text, then it will overwrite what is currently there
How can you read from a file once it is opened?
newFile.readLine()
-the program will always start reading from the first line of the external file
What is the file handling command which returns TRUE when the program is at the end of an external file?
newFile.endOfFile()
-used to signify when a program should stop reading a file
What do data bases order data into?
Fields (columns) and records(rows)
What do databases store data in?
Tables, made up of fields and records
What is a field?
A field is used to store a category
-a column of the table
What is a record?
A record uses the field to store details about a specific item
-a row of the table