Jump to content
  • Advertisement
Sign in to follow this  
McZ

Pascal code in several files

This topic is 4900 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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 *)
IMPLEMENTATION

function 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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!