Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 2 of 2 total
Thread Calling functions by reference
Thu, Nov 28 2013 6:29 AMPermanent Link

Matthew Jones

I am probably using the wrong term here, but I have a main form that does all the
talking to the server, and sub-forms that show the UI. The UI form asks the main
form to talk to the server, and then needs a callback to get the data. No problem
there - I store the callback in the form variables. However, since I can't have two
callbacks active, if the same request is called again, I want to immediately return
to the form to say that the first is not complete, and to try later. And this is
where I fall over.

external TOnCallDataManageComplete = procedure (nResult : Integer;
  szStatusMessage: String) of object;


procedure TMyForm.CallDataManage(szRequestJSON: String;
  fnCallDataManageComplete : TOnCallDataManageComplete);
begin
   if assigned(m_fnDataManageResult) then
   begin
       // ideal, but fails to compile AAAAA
       fnCallDataManageComplete(0, 'Please wait for first response');
       // works fine  BBBBB
       m_fnDataManageResult(0, 'Please wait for first response');
   end
   else
   begin
       m_fnDataManageResult := fnCallDataManageComplete;

       FSrvc.SendResponse(szRequestJSON, SendResponseComplete,
            OnResponseLinkError);
   end;
end;

Here, I would like to call the function that was passed in the parameter directly,
but it doesn't work. If I assign it to a form variable, then I can call it as
expected. (In this code, I am actually calling the previously stored function, as
it will actually be the same.)

Not a show stopper, but would be nice to know if it is me or the compiler. I do
wonder about the use of "external" here, but it seems to work. I just copied and
pasted from the RemObject SDK calls...

(For completeness, my forms are never really called TMyForm. Ick!)

/Matthew Jones/
Mon, Dec 2 2013 3:06 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Matthew,

<< Here, I would like to call the function that was passed in the parameter
directly, but it doesn't work. If I assign it to a form variable, then I can
call it as expected. (In this code, I am actually calling the previously
stored function, as it will actually be the same.) >>

This is fixed already.  There was an issue with events being used in arrays
also.

<< Not a show stopper, but would be nice to know if it is me or the
compiler. I do wonder about the use of "external" here, but it seems to
work. I just copied and pasted from the RemObject SDK calls... >>

You don't need the "external".  That's only for event types that are defined
outside of EWB in JS.

Tim Young
Elevate Software
www.elevatesoft.com
Image