views:

195

answers:

1

Hello,

How i can declare a global method in delphi prism using the __Global class?

And It is recommended to use global methods?

unfortunately I have not found any example.

Thanks in advance.

Bye.

+7  A: 

Yes, you can if you turn on the Allow Globals option in your project options. Then you can just do the following code:

interface

method GlobalMethod: Integer; public;

implementation

It is not recommended to use this construction. A more .Net way is to use a static/class method on a class.

type
  TSomeClass = public class
  public
    class method GlobalMethod: Integer;
  end;

// Call like this
I := TSomeClass.GlobalMethod;
Lars Truijens