Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 7 of 7 total
Thread ShowMessage Not Always Showing
Mon, Jul 27 2015 6:31 AMPermanent Link

squiffy

Telemix Ltd.

Avatar

If I have some code after the ShowMessage, the show message doesn't show. It's not a killer but it does make debugging a bit hard not knowing if the routine was just not called or whether I have a bug. Coupled with my other topic on Log not seeming to work I feel the force is against me this morning Smile

Example 1 -
In this example the ShowMessage fires as expected :

procedure TFrmPickADate.buildCalendar;
  var
     iRow, iCol, i,j, iStart, iDays: integer;
     dt: DateTime;
begin
  ShowMessage('in build');
  i:=1;
end;

Example 2 -
in this one it doesn't show at all but the code underneath executes fine :

procedure TFrmPickADate.buildCalendar;
  var
     iRow, iCol, i,j, iStart, iDays: integer;
     dt: DateTime;

begin
  ShowMessage('in build');
  i:=1;
  for iRow:=0 to 5 do
     for iCol:=0 to 6 do
        Grid1.Rows.Row[iRow].Value[iCol]:='X'; // X is just for debug to show code working. Change to ''
end;
Mon, Jul 27 2015 6:46 AMPermanent Link

Rick

On 27/07/15 20:31, squiffy wrote:
> If I have some code after the ShowMessage, the show message doesn't show. It's not a killer but it does make debugging a bit hard not knowing if the routine was just not called or whether I have a bug. Coupled with my other topic on Log not seeming to work I feel the force is against me this morning Smile
>
> in this one it doesn't show at all but the code underneath executes fine :
>
> procedure TFrmPickADate.buildCalendar;
>     var
>        iRow, iCol, i,j, iStart, iDays: integer;
>        dt: DateTime;
>
> begin
>     ShowMessage('in build');
>     i:=1;
>     for iRow:=0 to 5 do
>        for iCol:=0 to 6 do
>           Grid1.Rows.Row[iRow].Value[iCol]:='X'; // X is just for debug to show code working. Change to ''
> end;
>

The Javascript UI can be thought of as single threaded so any code
immediately following the ShowMessage will be executed before the modal
dialog is shown. I solved this issue by using the
InterfaceManager.Scheduler capability as follows:

procedure ....OnClick;
begin
  ShowProgress('Building');
  InterfaceManager.Scheduler.AddTask(add)'
end;

procedure ....add;
var
i: integer;
begin
  for i:=0 to 100 do
    begin
      <process>
    end;
  HideProgress;
  InterfaceManager.Scheduler.TaskComplete;
end;

ShowProgress displays a nice progress dialog and HideProgress removes
it. Make sure that TaskComplete is called after the process is done.

This works but you will probably notice that the progress animated image
doesn't turn like it's supposed to because once again the UI isn't being
updated during long running code. I resolved this by using further
TaskAdd calls within the process to allow the UI some update time.

--
Rick
Mon, Jul 27 2015 6:55 AMPermanent Link

squiffy

Telemix Ltd.

Avatar

Thanks Rick. Noted.

Though the docs do say that the ShowMessage displays a modal box - I assumed this to mean execution stopped at that point -

"The ShowMessage procedure shows a simple modal message dialog. The Msg parameter indicates the message to show."

This is why I hate the web Smile
Mon, Jul 27 2015 4:43 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

<< Though the docs do say that the ShowMessage displays a modal box - I assumed this to mean execution stopped at that point -  >>

No, that's not the definition of modal:

"In user interface design, a modal window is a graphical control element subordinate to an application's main window which creates a mode where the main window can't be used."

https://en.wikipedia.org/wiki/Modal_window

Tim Young
Elevate Software
www.elevatesoft.com
Mon, Jul 27 2015 5:01 PMPermanent Link

squiffy

Telemix Ltd.

Avatar

I've always, in my head, associated the disabling of the background with the halting of execution. Obviously I'm wrong. Thanks for clearing that up.

Age is horrible - I'm sure I used to know everything?
Mon, Jul 27 2015 6:11 PMPermanent Link

Rick

On 28/07/15 07:01, squiffy wrote:
> I've always, in my head, associated the disabling of the background with the halting of execution. Obviously I'm wrong. Thanks for clearing that up.
>

If you want to notify the user and halt execution you can add WebDOM to
the Uses and call the following:

Window.Alert('my message');

No code will execute until the alert is dismissed by the user.

--
Rick
Mon, Jul 27 2015 7:10 PMPermanent Link

Steve Gill

Avatar

<< Age is horrible - I'm sure I used to know everything? >>

I think I know everything but I can't remember. Smile

= Steve
Image