Jump to content

How return from Anonymous procedure Form


wsnet

Recommended Posts

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 ?

Link to comment
Share on other sites

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;

 

 

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...