I work at Delphi. It is necessary to organize such logic:

let's say, there is a bunch of radiobuttons on the form, and I want to select only the same procedure / function when selecting them.

Like that:

procedure someprocedure; begin writeLog('was clicked'+self.name); end; procedure formCreate; begin .......... for i:=1 to 99 do radiobutton[i].onclick:=someFunction()/someProcedure; .......... end; 

    1 answer 1

    Here's an option go ?:

    There is an array a: array [1..100] of TRadioButton; On FormCreate, they are created, or the array is filled with references to already existing objects.

    In the description of the form you add the desired procedure, here:

     type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); {--->}procedure SomeProcedure(Sender: TObject); private { Private declarations } public { Public declarations } end; 

    Further in the code after the word implementation you write:

     procedure TForm1.SomeProcedure(Sender: TObject); begin {что-то делаешь... Sender здесь - объект который вызывает, Если точно знаешь что он TRadioButton, и хочешь получить доступ к его полям пишешь: (Sender as TRadioButton).свойство } end; 

    Now you specify this procedure for all objects by pressing for i: = 0 to 99 do a [i] .onClick: = SomeProcedure;

    Well, like everything else to tell ...