UNIHIVE

Study Hub UNIPORT CSC 288

CSC 288 · Structured Programming

Turbo Pascal and Free Pascal tools for projects

The integrated environment, compiler directives, units for large programs, and organising a programming project.

Our notes

2 min read

The integrated development environment (IDE)

Turbo Pascal (Borland, from 1983) made Pascal popular with a fast compiler and an editor, compiler and debugger in one program. Free Pascal with its text-mode IDE (or the Lazarus IDE) carries the same ideas today on modern systems.
Main facilities:

  • Editor with syntax highlighting.
  • Compile (find syntax errors), Make (recompile changed units), Build (recompile everything), Run.
  • Debugger: step over, trace into, breakpoints, watches, evaluate expressions.
  • Help on every routine.

Compiler directives

Instructions to the compiler written as special comments:

  • {$R+} range checking on (catches array index errors).
  • {$I-} and {$I+} input/output checking off and on (test ioresult yourself).
  • {$Q+} overflow checking.
  • {$MODE OBJFPC} or {$MODE TP} in Free Pascal to choose the dialect.

Turn checks on while testing; they may be turned off for speed only after testing.

Units: building large programs

A unit is a separately compiled module with:
unit Stats;
interface
  function Mean(var a: array of real; n: integer): real;
implementation
  function Mean(var a: array of real; n: integer): real;
  var i: integer; s: real;
  begin
    s := 0;
    for i := 0 to n - 1 do s := s + a[i];
    Mean := s / n
  end;
end.
The main program says uses Stats; and calls Mean. Only the interface is visible to users of the unit: information hiding in practice. Standard units include crt (screen and keyboard), dos and sysutils.

Organising a project

  1. Specification: what the program must do (inputs, outputs, rules).
  2. Design: stepwise refinement, structure chart, data structures.
  3. Coding: one unit per area (input, processing, reports), consistent style.
  4. Testing: unit tests, then the whole; keep the test plan.
  5. Documentation: user guide and technical notes (comments, structure chart).
  6. Version control: keep dated copies (or use git) so a bad change can be undone.

The practical

UNIPORT requires a pass in a laboratory practical for this course: practise by writing complete small programs (a result processor, a library loan list, a phone book with a linked list) and testing them with planned data.

Exams usually ask

  • Describe the facilities of an IDE.
  • Explain compiler directives with examples.
  • Explain units, interface and implementation parts.

Common mistake

Putting all the code in one huge main program. Split it into units and procedures; each part can then be tested and changed on its own.

Written by the UniHive team in our own words. Spotted a mistake? Tell us on WhatsApp.

No reading links here yet

Our team adds free books, videos and practice for each topic, and opens every link before it goes up.

All CSC 288 topics

Report

Sign in to report this. It is free.

Is this your work (a lecturer, author or publisher)? Ask us to take it down.