[fpc-pascal] Externalization and inclusion of .PAS files (with GTK+) ?

ik idokan at gmail.com
Thu Feb 28 12:39:48 CET 2008


Please don't think in PHP or C when you use Pascal... in C the
compiler passes multiple times to be able to map between every line of
code and locate things on other includes.

The pascal's compiler does not include full units inside a big unit.
it includes sub implementations:

types.inc

type
  MyInt = type longint;

// end of  include file

main.pas

unit main;
interface
...
{$include types.inc}
...

implementation
...
end.

Please note that if you place things out of order, that is
include/declear a function before you included types, and that
function uses MyInt, the compiler will not be able to find the type
you wish to use.

Ido

On Thu, Feb 28, 2008 at 1:22 PM, T. Guilleminot <tom at guilleminot.org> wrote:
> Hi,
>
>  I'd like to simplify my programs by creating a short MAIN.PAS file and
>  several additional .PAS files called inside.
>  So I'd like to deport most of my code (procedures, functions...) to these
>  external .pas files and include them into the main.pas, a kind of
>  "include"-like in PHP.
>
>  I browsed the doc but between the "{$INCLUDE myfile1.pas}", the "uses"
>  clause (...) I'm quite lost and it has never worked for me yet.
>  As I code with GTK+ binding I also get GTK objects problem (eg : "unknown
>  object"...).
>
>  Does anyone able to provide me a simple example to achieve this ?
>  Thanks for any answer.
>  Tom
>
>
>  _______________________________________________
>  fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
>  http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>



-- 
http://ik.homelinux.org/



More information about the fpc-pascal mailing list