Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 8 of 8 total
Thread For Iteration Backwards
Sat, Jul 7 2012 1:34 PMPermanent Link

Walter Matte

Tactical Business Corporation

July 5/20112 Build

For X := 1 to 5 do
Begin
 Application.Desktop.ShowMessage(inttostr(X));
End;

ShowMessage
5
4
3
2
1

iterates 5 to 1 - expected 1 to 5

Walter
Sun, Jul 8 2012 2:53 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Walter


If its anything like Delphi my guess is that this is due to compiler optimisation. If you actually do something with the counter (eg set up an array and use it as an index into it) then you'll get the right answer.

Roy Lambert
Mon, Jul 9 2012 4:14 AMPermanent Link

Matthew Jones

I reckon that is because you are seeing the last message box first, then you click
that to reveal the 4th, etc. Remember that EWB is all async, so there is nothing to
stop the loop continuing after showing the first message box.

/Matthew Jones/
Mon, Jul 9 2012 4:29 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Matthew


>EWB is all async,

Interesting, I didn't know that still trying to sort out stuff on my day-to-day app before I can start playing with EWB Frown

Roy
Mon, Jul 9 2012 5:24 AMPermanent Link

Matthew Jones

Well, I guess it isn't all async, but UI will be. It's not about EWB being async,
but the platform it is operating within - the browser.

/Matthew Jones/
Mon, Jul 9 2012 7:15 AMPermanent Link

Matthew Jones

And just to confirm, having done this today, it is indeed async display. You may
want to look at Application.Desktop.MessageDlg which has a callback when complete,
which allows you to go to the next step once the user has confirmed. You'd need a
state-machine though, not a for-loop (that is, keep a form property that is the
current index, and on confirmation, increment it to move to the next one).

/Matthew Jones/
Mon, Jul 9 2012 7:16 AMPermanent Link

Walter Matte

Tactical Business Corporation

Matthew:

Thanks... async...  gotta get my backward thinking straightened out!

Walter
Mon, Jul 9 2012 9:16 AMPermanent Link

Rick

<Walter Matte> wrote in message
news:C11CB9A9-585B-4E64-8333-F0D6E5ECAC06@news.elevatesoft.com...
> For X := 1 to 5 do
> Begin
>  Application.Desktop.ShowMessage(inttostr(X));
> End;
>
> ShowMessage
> 5
> 4
> 3
> 2
> 1
>
> iterates 5 to 1 - expected 1 to 5
>
>


Hi Walter.

As pointed out by Matthew it's the way the browser is handling the modal
aspect of ShowMessage.

Try using window.alert(IntToStr((X)); instead. This calls the internal
javascript "alert" function which will show the messages modally as
expected.

--
Rick

Image