1

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.

Ken White
  • 123,280
  • 14
  • 225
  • 444
Salvador
  • 16,132
  • 33
  • 143
  • 245

1 Answers1

7

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
  • 42,837
  • 6
  • 126
  • 143