Skip to main content
A-LevelComputer ScienceFurther programming9618/21 · Oct/Nov 2023 · Q819 Marks

8 A class of students are developing a program to send data between computers. Many computers are connected together to form a wired network. Serial ports are used to connect one computer to another. Each computer: • is assigned a unique three-digit ID • has three ports, each identified by an integer value • is connected to between one and three other computers. Messages are sent between computers as a string of characters organised into fields as shown: <STX><DestinationID><SourceID><Data><ETX> Field number Field name Description n/a STX a single character marking the start of the message (ASCII value 02) 1 DestinationID three numeric characters that identify the destination computer 2 SourceID three numeric characters that identify the source computer 3 Data a variable length string containing the data being sent (Minimum length is 1 character) n/a ETX a single character marking the end of the message (ASCII value 03) For example, the following message contains the data "Hello Kevin" being sent from computer "101" to computer "232": <STX>"232101Hello Kevin"<ETX> Each computer will run a copy of the same program. Each program will contain a global variable, MyID of type string, that contains the unique ID of the computer in which the program is running. The programmer has defined the first two program modules as follows: Module Description Transmit() (already written) • takes two parameters: ○ a string containing a message ○ an integer containing a port number • transmits the message using the given port SendFile() • takes three parameters: ○ a string containing a text file name ○ a string containing a Destination ID ○ an integer containing a Port number • transmits the file one line at a time • transmits a final message with data string "****"

  1. (a)Write pseudocode for module SendFile(). Assume: • module Transmit() has already been written and is used to transmit a message • the value of MyID may be used as SourceID • the file specified contains no blank lines • the file specified does not contain the line "****"[7]
  2. (b)Module SendFile() is used to copy a file from one computer to another. A module within the program running on the destination computer will receive the data and write it to a new file. Explain why module SendFile() transmits the message with data string "****" after the last line of the file.[2]
  3. (c)(i)One of the text files to be sent contains several blank lines (lines that do not contain any text). Explain why this is a problem.[2]
  4. (c)(ii)Explain how the message format could be changed to allow a blank line to be sent.[2]
  5. (d)A new module has been defined: Module | Description -------|------------ GetField() | • takes two parameters: | ○ a string containing a message | ○ an integer containing a field number | • If the field number is valid (in the range 1 to 3, inclusive), it | returns a string containing the required field, otherwise it returns | an empty string. As a reminder, a message is defined as follows: <STX><DestinationID><SourceID><Data><ETX> Field number Field name Description Not applicable STX a single character marking the start of the message (ASCII value 02) 1 DestinationID three numeric characters that identify the destination computer 2 SourceID three numeric characters that identify the source computer 3 Data a variable length string containing the data being sent (Minimum length is 1 character) Not applicable ETX a single character marking the end of the message (ASCII value 03) Write pseudocode for module GetField().[6]

Mark scheme

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

  1. [1] `OPENFILE FileName FOR READ` and `CLOSEFILE FileName`
  2. [1] Loop using `WHILE NOT EOF(FileName)` and `ENDWHILE`
  3. [1] `READFILE FileName, FileData` inside the loop
  4. [1] Form message: `FileData ← STX & DestID & MyID & FileData & ETX` (correct components)
  5. [1] `CALL Transmit(FileData, Port)` inside the loop (with correctly formed message and port)
  6. [1] `CALL Transmit(STX & DestID & MyID & "****" & ETX, Port)` after the loop (all parts present)
  7. [1] To indicate that all lines of the file have been sent / it is the end of the transmission / file transfer
  8. [1] So that the receiving program can stop waiting for further data / the file can be closed / saved
  9. [1] The current message format specifies a minimum length of 1 character for the `Data` field, so a zero-length data field is not allowed.
  10. [1] Therefore, a blank line (which would result in a zero-length `Data` field) cannot be sent.
  11. [1] Append a special character (e.g., a specific non-printable ASCII character or a unique symbol) to the start of the message text
  12. [1] The receiving module would interpret this special character as a blank line (and remove it before displaying)
  13. [1] Change the message protocol to include an additional field (e.g., a Boolean flag) to act as an indicator
  14. [1] The receiving module would check this flag; if true, it interprets the `Data` field as a blank line, even if it's empty.
  15. [1] Use of `CASE...ENDCASE` or `IF...THEN...ENDIF` for field number selection
  16. [1] Correct extraction for Field 1 (`MID(Msg, 2, 3)`) and Field 2 (`MID(Msg, 5, 3)`)
  17. [1] Correct calculation for length of Field 3 (`LENGTH(Msg) – 8`)
  18. [1] Correct extraction for Field 3 (`MID(Msg, 8, LENGTH(Msg) – 8)`)
  19. [1] Return an empty string in case of an invalid field number (e.g., using `OTHERWISE : RetString ← ""` or initialising `RetString` to `""`)
  20. [1] `RETURN RetString` after the selection structure

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
Further programming, A-Level Computer Science (syllabus 9618). Structured question, 19 marks.
Source
A-Level Computer Science, Oct/Nov 2023 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