Pascal code in several files

Started by
0 comments, last by Toolmaker 19 years, 3 months ago
lets say I have my code like this: Program myprog; function MyFunc(x:integer):integer; begin (* some code *) end; begin (* some code that uses the function above *) end. how can I split this into two files? one that containes the main program loop and the other that contains the function 'MyFunc' ? I have search on google and tried different things but nothing works for me, I'm using gpc on Solaris if that is an issue. Thanks in advance for your help.
Advertisement
You have to write a Pascal Unit in order to do this. From my old Pascal book(Using Borland Pascal 7), this is what you have to do:

UNIT MyUnit;INTERFACE (* NO NEED FOR A ; *)(* Perhaps a USES statement here for required units *)USES Crt;(* Define the function prototypes here *)function MyFunc(x : integer) : integer;function AnotherFunc(n : integer) : integer;(* Start the implementation *)IMPLEMENTATIONfunction MyFunc(x : integer) : integer;VAR   y : integer;BEGIN   (* Code *)END;function AnotherFunc(n : integer) : integer;VAR   z : integer;BEGIN   (* Code *)END;END. (* End the unit *)


This is what I got from glancing through my Pascal book, not sure if it still works like that.

Toolmaker

This topic is closed to new replies.

Advertisement