Pascal from the ground up
The teaching language that still compiles
- Beginner
- 12 chapters
- 179 min read
Learn Pascal by running it: the program header and writeln, variables and the five basic types, div and mod, decisions with if and begin blocks, three kinds of loop, arrays with low and high, functions and procedures with var parameters, records and arrays of records, constants and type names, text with length, copy, pos and upcase, case statements, and a capstone inventory report that uses them all.
What You'll Learn
- Write and run a Pascal program, and know why the last end carries a period
- Declare variables in a var block and tell integer, real, string, boolean and char apart
- Use div and mod, and format a real so it prints the decimals you want
- Choose a path with if then else, and group statements with begin and end
- Repeat work with for, while and repeat until, and stop each one on time
- Keep values in an array and walk it with low and high
- Name work as functions and procedures, and pass a var parameter when it must change
- Group fields into a record and hold a list of records in one array
- Name values with const and shapes with type, in the order the compiler expects
- Measure, slice and search text with length, copy, pos and upcase
- Pick a branch from a list of labels with case, and catch the rest with else
- Build a capstone: records, a constant table, running totals and a printed report
Prerequisites
- No Pascal at all — the course starts at the program header
- Any experience with one other language makes the early chapters quicker, but none is assumed
Course Content
- 01Your first Pascal programNot started
What Pascal is for, the three parts every program is built from, and your first run: three lines printed with writeln.
- 02Variables and the five typesNot started
Naming values in a var block, the five types a beginner needs, and how each one is printed — including the decimal that needs a format.
- 03Arithmetic, div and modNot started
The operators Pascal gives you, why div throws the fraction away, how mod returns the remainder, and the one slash that always gives a real.
- 04Decisions with if and elseNot started
Comparing values with the right operators, branching with if then else, and why a branch with two statements needs begin and end around it.
- 05Three loops: for, while and repeatNot started
A counted for loop, a while loop that checks first, and a repeat loop that checks last — and how to tell which one a piece of work wants.
- 06Arrays, low and highNot started
Keeping a row of values under one name, choosing the indexes, and using low and high so a loop survives a change to the size.
- 07Functions and proceduresNot started
Naming a piece of work: a function hands a value back through its own name, a procedure does not, and a var parameter lets it change the caller.
- 08Records, and arrays of themNot started
Grouping a name and a score into one type, reading the fields with a dot, and keeping a whole list of records in a single array.
- 09Naming things: const and typeNot started
Turning a number into a name with const, giving a type a short name of your own with type, and keeping both in the order the compiler expects.
- 10Text: length, copy, pos and upcaseNot started
A string is a row of characters you can measure, slice and search: length, copy, pos, upcase and the plus sign that joins two pieces.
- 11Choosing with caseNot started
One selector, several labelled branches: a case statement replaces a long chain of ifs, groups labels together, and never falls through.
- 12Putting it together: an inventory reportNot started
A capstone that uses the whole course at once: a record type, a constant table, an array of records, a loop that totals each line, and a printed report.
