Properties - Delphi Compatibilty

Hi,

i have some Delphi 2007-Code like this:

property DisplayAngle: boolean index integer(pfDisplayAngle) Read GetFlags Write SetFlags;
property DisplayRadius: boolean index integer(pfDisplayRadius) Read GetFlags Write SetFlags;

How do i translate this kind of “index” to oxygene? There´s a whole lot of such properties, so it would be very helpful, if there´s a solution.

Thanks in advance,
wh

Werner,

We have just added support for this index syntax, in Delphi Compatibility Mode. if you update to the latest, .2755, it should work.

Wow! That´s great news. I will try it in the next days. Thank you very much!

1 Like

Just confirmed it works with enums as you showed it, and even without needing the cast to integer:

namespace ConsoleApplication22;

type
  Program = class
  public

    class method Main(args: array of String): Int32;
    begin
      // add your own code here
      writeLn('The magic happens here.');
    end;
    
    property DisplayAngle: Boolean index pfDisplayAngle Read GetFlags Write SetFlags;
    property DisplayRadius: Boolean index pfDisplayRadius Read GetFlags Write SetFlags;

    method GetFlags(a: Foo);
    begin
      
    end;
    
    method SetFlags(b: Boolean; a: Foo);
    begin
      
    end;

  end;
  
  Foo = public enum(pfDisplayAngle, pfDisplayRadius);

end.
1 Like

Hi,

I just installed 2755 to try it out. Works … - but for true compatibility there is one exception: the setter method should take “Index” as parameter 1, “Value” as parameter 2. It’s hardly worth mentioning, just for the sake of completeness.

But for me it would be ok.
Thanks again.
Werner

From the original documentation: “… for a write procedure, it must be the second-to-last parameter (preceding the parameter that specifies the property value).”

Oops yes, I reopened E24454.