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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...