TASK 3
Key focus: File handling using a text file
String handling built-in functions
TASK 3.1
Using a text editor, create a sample text file containing a set of computing terms, each followed by a
one line description.
The typical file contents will be as shown below with each term and description on alternate lines.
serial
file organisation with data items in no particular order
sequential
file organisation where the data items are in some key field order
file
collection of data items
input
file mode which allows data to be written to the file
output
file mode which allows data to be read from the file
append
file mode which allows new data items to be added to the end of the file
FILEREAD
pseudocode term to read a data item from a file
FILEWRITE
pseudocode term to write a data item to a file
EOF
pseudocode for a function which returns TRUE/FALSE to indicate whether the end of file has been
reached
TASK 3.2
Write code to produce a menu for the user as shown.
TASK 3.3
Code option 1 on the menu as a procedure SearchByTerm which:
• prompts the user for the search term
• searches the file for the term and reports either:
o FOUND ... followed by its description, or
o TERM NOT FOUND
4
Typical output using the sample file would be:
TASK 3.4
Code option 2 on the menu as a procedure SearchDescriptionsForKeyword which:
• prompts the user for the keyword
• searches all the descriptions in the file for the presence of that keyword and reports either:
o the one or more terms whose description contained the keyword, or
o NO DESCRIPTIONS FOUND containing this keyword.
Typical output using the sample file would be: