wsnet Posted June 6, 2019 Share Posted June 6, 2019 I'am use anonymous procedure for Callback Form: Why the variable does not return procedure CallActionFrm2(var I: integer); var AfrmBaseDictionaryList: TfrmBaseDictionaryList; tmp: Integer; begin tmp := I; with TfrmBaseDictionaryList.Create(UniApplication) do begin ShowModal( procedure(Sender: TComponent; AResult: Integer) begin if AResult = mrOk then begin tmp := 100; end; end ); I := tmp; end; end; ... procedure TfrmAdmPlanItem.btnSearchClick(Sender: TObject); var id: Integer; begin id := 1; CallActionFrm2(id); edtInn.Text := IntToStr(id); // get id = 1, but id = 100! end; Why the variable id does not return ? Quote Link to comment Share on other sites More sharing options...
Pep Posted June 7, 2019 Share Posted June 7, 2019 Hello, try this: procedure CallActionFrm2(I: integer); var AfrmBaseDictionaryList: TfrmBaseDictionaryList; tmp: Integer; begin tmp := I; with TfrmBaseDictionaryList.Create(UniApplication) do begin ShowModal( procedure(Sender: TComponent; AResult: Integer) begin if AResult = mrOk then begin tmp := 100; edtInn.Text := IntToStr(tmp); end; end ); end; end; ... procedure TfrmAdmPlanItem.btnSearchClick(Sender: TObject); var id: Integer; begin id := 1; CallActionFrm2(id); end; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.