Avatar of Member_2_7965240
Member_2_7965240

asked on 

Delphi: Android anonymous method problem

Hello,

I have an Android app written in Delphi Seattle.

I need to show a form modally in a function then get back the value of an Edit object.

However, this doesn't work:

Function GetMyValue: String;
Begin
  Form1:=TForm1.Create(Nil);
.....

     ShowModal(
         procedure(ModalResult: TModalResult)
         begin

           if ModalResult = mrOK then
             Begin
              Result  := MyEdit.Text;
             End;
             
         end);

I get a compiler message: [dcc32 Error]  E2555 Cannot capture symbol 'Result'
I know that in anonymous method I cannot refer to the main functions result, but I need to get back the text when the user closes the form.

How can I do that?
Thank you very much!
Delphi

Avatar of undefined
Last Comment
Sinisa Vuk

8/22/2022 - Mon