[fpc-pascal] How do I load external Pascal code?
jonas.maebe at elis.ugent.be
Thu Oct 13 22:42:07 CEST 2011
On 13 Oct 2011, at 22:32, Andrew Pennebaker wrote:
> On Thu, Oct 13, 2011 at 3:40 PM, Jonas Maebe <jonas.maebe at elis.ugent.be>wrote:
>> On 13 Oct 2011, at 21:37, Andrew Pennebaker wrote:
>>> Is it possible to have a begin/end declaration in a unit a la C's main
>>> function? I would like my units to double as libraries and executables.
>> Yes: http://www.freepascal.org/docs-html/ref/refse72.html
> Hmm. I tried rewriting begin/end as initialization/end, but scriptedmain.p
> still won't compile to an executable. fpc just creates a .PPU file.
As the above-mentioned page says (emphasis mine):
A unit contains a set of declarations, procedures and functions that can be *used by a program* or another unit.
The initialization parts of the units are executed in the order that the compiler loaded the units *when compiling a program*. They are *executed before the first statement of the program* is executed.
Here's how you write a program: http://www.freepascal.org/docs-html/ref/refse71.html
You may also want to go through the entire tutorial I linked to earlier: http://www.learn-programming.za.net/programming_pascal_learn01.html
More information about the fpc-pascal