WasmPascal Tutorials

Fifteen lessons that teach you Pascal from nothing, written for WasmPascal — the in-browser compiler that turns Pascal source into WebAssembly on the same page.

These lessons are the written form of the Learn Pascal tutorial built into WasmPascal itself. They assume no prior Pascal and no toolchain: you write a program on the left, press Run, and the freshly compiled WebAssembly runs on the right. Nothing to install, nothing to rebuild.

Each lesson explains one idea, shows a complete program, and then invites you to paste it into the editor and poke at it. Work through them in order, or jump straight to whatever you need.

The lessons

  1. 1Start hereStart learning Pascal with WasmPascal: what the in-browser compiler does, how the editor and the output panel work together, and how to run your first program without installing anything.
  2. 2Program structureHow a Pascal program is put together in WasmPascal: the program and library headers, the optional uses clause, begin..end statement blocks, and the final end.
  3. 3Values and typesThe Pascal type system as WasmPascal implements it: integers, floats, booleans, characters, enumerations, subranges, records, arrays, pointers and strings.
  4. 4Variables and constantsDeclaring variables and constants in Pascal with WasmPascal: the assignment operator, compile-time constants, and printing several values with a single writeln.
  5. 5Numbers: integer mathInteger arithmetic in Pascal: div and mod, real division with the slash operator, and why an unsigned div or mod needs both operands unsigned in WasmPascal.
  6. 6FloatsFloating-point arithmetic and the math builtins in WasmPascal: Sqrt, Sqr, Abs, Trunc, Round, Pi, trigonometry, logarithms, and field widths when printing.
  7. 7Console I/O: write, readlnConsole input and output in Pascal: write and writeln, field widths, read and readln, the fixed 80x25 character screen, and String handling in WasmPascal.
  8. 8Control flowControl flow in Pascal: if, for, while and repeat..until, case arms with lo..hi ranges, break and continue, and Delphi 13 style ternary expressions.
  9. 9Procedures and functionsWriting procedures and functions in WasmPascal: assigning to the function name, var parameters by address, early exit with a value, string parameters, and label/goto.
  10. 10Records, arrays, and pointersRecords, static arrays and pointers in Pascal: nesting, SizeOf, nil, pointer arithmetic with Inc and Dec, variant records, and multi-dimensional arrays.
  11. 11with and set ofThe with statement and Pascal sets in WasmPascal: bitmask set operators, membership tests, set constructors, and why set variables have to be globals.
  12. 12Units and multi-file projectsOrganising a WasmPascal project: units with interface and implementation sections, the uses clause, and the Crt, Classes and WEB units built into the compiler.
  13. 13Host ABIs and the consoleHow WasmPascal chooses a host ABI for your program: console, pascaldom, batchiness and basic_canvas, and how to reach the DOM from Pascal with uses WEB.
  14. 14Objects & classesObject Pascal in WasmPascal: value-type objects, reference-type classes, constructors, virtual methods, inheritance and polymorphism.
  15. 15What nextWhere to go after the WasmPascal tutorials: the examples dropdown, games like pascalsweep and pascaloid, and why breaking working programs is the fastest way to learn.

Prefer to read the source, or grab the programs for yourself? The tutorials and every example they mention live in the wasmpascal_examples repository on GitHub.