How to give setter a second parameter in Delphi?

I want to know if we can do this in Delphi: I have a private procedure:

procedure SetMySend(const oValue: TTM_MySend_Profile; displayValue: string = '...'); 

I have a public property:

 property MySend: TTM_MySend_Profile displayLocateID '...' read FMySend write SetMySend; 

Can I give the displayValue parameter here as the second setter parameter? I can not compile this file.

I cannot figure out the right way to do this and wonder if I can do this in Delphi. Thanks for the help!

+4
source share
1 answer

The property setter for a property accepts only one parameter of the same type as the property. There is no syntax that allows you to write the type of code you are trying to write. Please note that I ignore array properties that are not relevant here.

What you need to do is write a special installer that provides an additional parameter to your SetMySend function.

 procedure SetMySend(const Value: TTM_MySend_Profile; const displayValue: string); overload; procedure SetMySend(const Value: TTM_MySend_Profile); overload; property MySend: TTM_MySend_Profile read FMySend write SetMySend; 

And then in the implementation you write

 procedure TMyClass.SetMySend(const Value: TTM_MySend_Profile); begin SetMySend(Value, '...'); end; 

You could grab index qualifiers to create something similar, but I would not recommend this.

+6
source

Source: https://habr.com/ru/post/1390487/


All Articles