High Class Pack – 11.11.2026

REVISION GUIDE: PROCEDURES, PARAMETERS & TEXT FILES

What you are learning: How to organise code into a procedure, pass information into it, and save text to an external file safely.

1. Procedures and parameters

Procedure: A named block of code that performs a task. It can be called whenever that task is needed. A procedure does not have to return a value.

Parameter: A variable listed in the procedure definition. It receives information when the procedure is called.

Argument: The actual value or variable supplied when the procedure is called.

Example: sending information into a procedure

PROCEDURE DisplayMessage(message)
    OUTPUT message
ENDPROCEDURE

In this example, message is a parameter. Calling DisplayMessage(“Welcome”) passes the text Welcome as its argument.

2. Working with external text files

A text file stores information outside the program so it can be kept and accessed later. A program commonly follows three stages:

1. OPENConnect to the file. Choose the correct file name/path and mode.
2. WRITESend the text data to the open file.
3. CLOSEClose the file when finished so the operating system can complete the write and release the resource.

Common file modes: Write mode creates a file or replaces its existing contents; append mode adds new content to the end; read mode retrieves existing content. Check the question or language rules to choose the correct mode.

3. A different worked example

Imagine a program that needs to save a customer’s receipt summary. The procedure should receive the summary and the destination file name.

PROCEDURE WriteReceipt(receiptText, filePath)
    receiptFile = OPEN(filePath, “write”)
    WRITE receiptText TO receiptFile
    CLOSE receiptFile
ENDPROCEDURE

How it works: The procedure has two parameters. The first carries the content; the second identifies where it should be saved. The file is opened, the content is written, and the file is closed.

4. How to plan a file-handling procedure in an exam

  1. Identify the inputs – Decide what information the procedure needs and what identifies the file.
  2. Define the procedure – Give it a meaningful name and include a parameter for each required input.
  3. Open the file – Use the supplied file name/path and an appropriate mode.
  4. Write the data – Write the required string or text variable to the open file.
  5. Close the file – Make sure the file is closed after writing.

5. Exam keywords and common mistakes

Remember these words: procedure • parameter • argument • file name/path • open • write • append • read • close.

Avoid these mistakes: forgetting to pass all required inputs; writing before opening the file; using the wrong file mode; confusing the file name with the data; forgetting to close the file; placing file operations outside the procedure when the task asks for them inside it.

Exam tip: Use clear, ordered steps. Check that every input is used and that the file is closed.

Was this article helpful?
YesNo