Run and edit Cambridge IGCSE Computer Science 0478 pseudocode directly in VS Code — desktop and web.
⚠️ How files work — read this before using OPENFILE / READFILE / WRITEFILE
File behaviour depends on where your program is open, because OPENFILE needs a real
folder to resolve a filename against. This matters most on iPad / web, where there is
often no filesystem at all.
Where a file is read from, in priority order:
- Embedded data — a
//<<FILE … //>>block in your program (see below). Always used if present, on every platform. - Session memory — a file your program wrote earlier in this VS Code window (kept until you reload the window; never saved to disk if the document is unsaved).
- The real folder on disk — only when your program file is saved inside a folder (desktop, or a web repo such as github.dev).
Where a file is written:
- Saved in a folder → written to a real file next to your program.
- Unsaved / untitled document → kept in session memory only (lost on window reload).
The common failure: running file code from an unsaved tab with no folder open (typical on iPad). There is no folder to read a provided data file from, so
READFILEreports “file not found.” Fix it by embedding the data (below) or by saving your program into a folder that also contains the data file.
Embedding input data (works everywhere, including iPad)
When a question gives you a data file to read, paste it into your program as a comment block. The extension loads it as if it were a real file — no filesystem needed:
//<<FILE numbers.txt
//10
//25
//7
//>>
DECLARE n : INTEGER
OPENFILE "numbers.txt" FOR READ
READFILE "numbers.txt", n // reads 10
OUTPUT n
CLOSEFILE "numbers.txt"
- Open with
//<<FILE <name>, write each data line prefixed with//, close with//>>. - The text after the
//is taken verbatim (//10→10,// 10→10). - Filenames are case-sensitive and must match exactly between the block and your
OPENFILE—"Numbers.txt"≠"numbers.txt". (Note: this is unlike variable names, which are case-insensitive.) - Use a plain name like
data.txt; don't use folder paths.
When a run uses embedded data or session memory, the terminal prints a [files] … note so
you always know where the data came from.
Quick start
- Create a file with the
.pseudoor.0478extension. - Write your pseudocode. Syntax highlighting and error checking activate automatically.
- Open the Command Palette (
Cmd+Shift+P/Ctrl+Shift+P), type 0478, and run 0478: Run Pseudocode File. - A terminal opens.
INPUTstatements pause and wait for you to type a value — press Enter to submit.
Debugging
Open a .pseudo / .0478 file and press F5 to start debugging — no launch.json
needed. Execution pauses at the first statement.
- Breakpoints — click the gutter next to any line.
- Step — Step Over (
F10), Step Into (F11), Step Out (Shift+F11), Continue (F5). - Variables — the VARIABLES panel shows every variable in the current scope; arrays expand to their elements.
- Watch — add an expression to the WATCH panel to track its value as you step.
- Debug Console — type an expression (e.g.
Score + 10,Grid[1,1],LENGTH(Name)) to evaluate it in the current scope. - Hover — hover over a variable in the editor while paused to see its value.
OUTPUT goes to the Debug Console; INPUT prompts via an input box.
Example
DECLARE Name : STRING
DECLARE Score : INTEGER
OUTPUT "Enter your name: "
INPUT Name
OUTPUT "Enter score (0-100): "
INPUT Score
IF Score >= 70
THEN
OUTPUT "Well done, ", Name, "!"
ELSE
OUTPUT "Keep practising, ", Name
ENDIF
Language features
| Feature | Supported |
|---|---|
| Data types | INTEGER REAL CHAR STRING BOOLEAN |
| Variables & constants | DECLARE / CONSTANT |
| Arrays | 1-D and 2-D with explicit bounds |
| Selection | IF/THEN/ELSE/ENDIF, CASE OF/ENDCASE |
| Iteration | FOR/NEXT, WHILE/ENDWHILE, REPEAT/UNTIL |
| Procedures | PROCEDURE/ENDPROCEDURE, CALL |
| Functions | FUNCTION/ENDFUNCTION, RETURN |
| Built-ins | LENGTH LCASE UCASE SUBSTRING ROUND RANDOM DIV MOD |
| I/O | INPUT / OUTPUT |
| File I/O | OPENFILE READFILE WRITEFILE CLOSEFILE |
| Comments | // line comment |
Strict typing
Types are enforced at runtime, matching exam marking:
INTEGER → REALwidening is allowed;REAL → INTEGERis not.CHARsatisfies aSTRINGparameter; the reverse is not allowed.- Array indices are bounds-checked; out-of-range access is a runtime error.
Syntax reference (quick)
// Variables
DECLARE Counter : INTEGER
DECLARE Grid : ARRAY[1:3, 1:3] OF CHAR
CONSTANT Pi ← 3.14159
// Assignment (← or ASCII alias <-)
Counter ← 0
Grid[1,1] ← 'X'
// Operators
// Arithmetic : + - * / ^ (power)
// Integer : DIV(a,b) MOD(a,b)
// Comparison : = <> < <= > >=
// Boolean : AND OR NOT
// Loops
FOR i ← 1 TO 10 STEP 2
OUTPUT i
NEXT i
WHILE Count > 0 DO
Count ← Count - 1
ENDWHILE
REPEAT
INPUT Answer
UNTIL Answer = "yes"
// Procedure
PROCEDURE Greet(Name : STRING)
OUTPUT "Hello, ", Name
ENDPROCEDURE
CALL Greet("World")
// Function
FUNCTION Square(n : INTEGER) RETURNS INTEGER
RETURN n * n
ENDFUNCTION
OUTPUT Square(7)
Assignment operator
The spec uses ←. This extension also accepts the ASCII alias <- for easier typing — both work identically.