Salvador
Salvador

Reputation: 16472

How i can declare a global method in Oxygene

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.

Upvotes: 1

Views: 532

Answers (1)

Lars Truijens
Lars Truijens

Reputation: 43602

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;

Upvotes: 7

Related Questions