Delphi: Android anonymous method problem

Member_2_7965240
Member_2_7965240 used Ask the Experts™
on
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!
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Software architect
Top Expert 2012
Commented:
cause ShowModal on Android is non-blocking - there is no way to make (without waiting and Application.Processmessages) function to return value. Better make callback procedure where your result will trigger some other code. Look at this or this examples. You must redesign your app, but all be good...

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial