[fpc-pascal] How do I load external Pascal code?

J├╝rgen Hestermann juergen.hestermann at gmx.de
Fri Oct 14 07:19:04 CEST 2011

Andrew Pennebaker schrieb:
 > In some languages, especially scripting languages, units can serve 
dual purposes. They can act as both a library and a self-sufficient 
program. RosettaCode describes this behavior as scripted main. If it's 
possible to compile a Pascal unit such that it executes initialization 
code as if it were a typical program/begin/end file, then this dual 
behavior can be achieved.

In Pascal, units are only libraries of code. You need a separate program 
that loads the unit (with "uses") to get an executable. If you don't 
reuse the code in the unit you don't even need a unit, just write a 
program with the code. Units serve the only purpose of code libraries 
you can use in multiple programs.

More information about the fpc-pascal mailing list