Skip to main content
A-LevelComputer ScienceProgramming9618/21 · Oct/Nov 2022 · Q819 Marks

A teacher is designing a program to perform simple syntax checks on programs written by students. Student programs are submitted as text files, which are known as project files. A project file may contain blank lines. The teacher has defined the first program module as follows: Module CheckFile() Description • takes the name of an existing project file as a parameter of type string • returns TRUE if the file is valid (it contains at least 10 non-blank lines), otherwise returns FALSE

  1. (a)Write pseudocode for module CheckFile().[7]
  2. (b)CountErrors() is called to check the project file Jim01Prog.txt and to stop if more than 20 errors are found. Write the pseudocode statement for this call.[2]
  3. (c)Write pseudocode for module CountErrors(). Assume CheckFile() and CheckLine() have been written and can be used in your solution.[8]
  4. (d)Module CheckLine() includes a check for syntax errors. Two examples of syntax error that cannot be detected from examining a single line are those involving selection and iteration. Give two other examples.[2]

Mark scheme

Marking points from the official mark scheme (Oct/Nov 2022). The mark or mark type is shown in brackets.

  1. [1] (a) Function heading and ending including parameter and return type
  2. [1] (a) Declaration and initialisation of local Integer for Count
  3. [1] (a) OPEN in READ mode and CLOSE
  4. [1] (a) Conditional loop until EOF ()
  5. [1] (a) Read a line in a loop
  6. [1] (a) If non-blank, increment count in a loop
  7. [1] (a) Terminate loop when 10 non-blank lines have been read
  8. [1] (a) Return Boolean in both cases
  9. FUNCTION CheckFile(ThisFile : STRING) RETURNS BOOLEAN DECLARE Valid : BOOLEAN DECLARE ThisLine : STRING DECLARE Count : INTEGER Count <- 0 Valid <- FALSE OPEN ThisFile FOR READ WHILE NOT EOF(ThisFile) AND Valid = FALSE READFILE ThisFile, ThisLine IF ThisLine <> "" THEN Count <- Count + 1 IF Count > 9 THEN Valid <- TRUE ENDIF ENDIF ENDWHILE CLOSEFILE ThisFile RETURN Valid ENDFUNCTION
  10. [1] (b) Module name, at least one parameter in brackets and one parameter correct
  11. [1] (b) Completely correct statement
  12. CALL CountErrors("Jim01Prog.txt", 20)
  13. [1] (c) Procedure heading and ending including parameters
  14. [1] (c) Declaration and initialisation of local Integer value for ErrCount
  15. [1] (c) Use of CheckFile(),output message and terminate if it returns FALSE
  16. [1] (c) Conditional loop until EOF ()
  17. [1] (c) ...or ErrCount > MaxErrors
  18. [1] (c) Read line and use as parameter to CheckLine() in a loop
  19. [1] (c) Test return value and increment ErrCount if non-zero in a loop
  20. [1] (c) Output either message once only as appropriate
  21. PROCEDURE CountErrors(ThisFile : STRING, MaxErrors : INTEGER) DECLARE ErrCount, ThisError : INTEGER DECLARE ThisLine : STRING ErrCount <- 0 IF CheckFile(ThisFile) = FALSE THEN OUTPUT "That program file is not valid" ELSE OPEN ThisFile FOR READ REPEAT READFILE ThisFile, ThisLine ThisError <- CheckLine(ThisLine) IF ThisError <> 0 THEN ErrCount <- ErrCount + 1 ENDIF UNTIL ErrCount > MaxErrors OR EOF(ThisFile) IF EOF(ThisFile) = FALSE THEN OUTPUT "Check terminated – too many errors" ELSE OUTPUT "There were ", ErrCount, " errors." ENDIF CLOSEFILE ThisFile ENDIF ENDFUNCTION
  22. [1] (d) Incorrect block structure. Missing keyword denoting part of block (for example ENDPROCEDURE, ENDFUNCTION, ENDTYPE)
  23. [1] (d) Data type errors, for example, assigning an integer value to a string
  24. [1] (d) Identifier used before it is declared
  25. [1] (d) Incorrect parameter use

Write your answer and get it marked

On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.

Sign up free →

About this question

Topic
Programming, A-Level Computer Science (syllabus 9618). Structured question, 19 marks.
Source
A-Level Computer Science, Oct/Nov 2022 Paper 2 Variant 1, question 8.

Questions and mark schemes are from past examination papers and remain the copyright of the exam board. How Oracle Prep builds its content

Related Computer Science questions

© 2026 Oracle Prep