Board index » delphi » Help with making new function Global.

Help with making new function Global.

Carl <swed...@vcnet.com>,

Quote
>Being new to Pascal, I wonder if it is possible to take one of my
>"homemade" functions and make it global, like the built in Turbo
>Pascal functions, and if so, how would I go about it.

>It would be nice not to have to repeat it in every program that could
>benefit from it.

  Create a unit which contains your global variables and procedures.

    unit MyGlbl;
    interface

    const
      MyCopyright = 'Copyright 1995, Eminent Domain Software';
      MyName      = 'Ed Salgado';

    procedure WriteCopyRight;

    implementation

    procedure WriteCopyRight;
    begin
      WriteLn (MyCopyright);
      WriteLn (MyName);
    end;  { WriteCopyRight }

    end.  { MyGlbl }

  You now have a global unit which you can place in the uses clause of
any of your programs.

    program MyProg;
    uses
      MyGlbl;

    begin
      WriteCopyRight;   {calls MyGlbl's WriteCopyRight procedure}
    end.  { MyProg }

Hope this helps.

-Ed Salgado
 Eminent Domain Software

 

Re:Help with making new function Global.


Quote
swed...@vcnet.com (Carl Jacobson) wrote:
>Hi,

>Being new to Pascal, I wonder if it is possible to take one of my
>"homemade" functions and make it global, like the built in Turbo
>Pascal functions, and if so, how would I go about it.

>It would be nice not to have to repeat it in every program that could
>benefit from it.

You should make a Unit containing your own goodies, say MYGOODIS.PAS and link
them in with your program in a uses clause:

program TESTMGDIS;
Uses MyGoodis;

begin
   Goody1(...);
   Goody2 (...);

Other Threads