Page 1 of 1

Display Status of a Repeat Loop

Posted: Wed Dec 15, 2010 6:45 pm
by richardmac
Hello,
Just got on board with LiveCode recently, previous a MetaCard guy. Here's my issue. In a repeat loop, I used to put a running count into a field so I could see the progress of the script. This does not work in LiveCode so I'm looking for a workaround.

Example:

repeat with i = 1 to 1000
-- do some action here
put i into field "status"
end repeat

When run, the field "status" would flash the numbers going by and I could see how far the script was. Now it does not. Instead of 1000, picture the number of lines in a 15 MB text file - like 70 thousand lines or so. I'd like to be able to see where I am in the process while the script runs. Best workaround/idea?

Re: Display Status of a Repeat Loop

Posted: Wed Dec 15, 2010 7:01 pm
by Klaus
Hi Richard,

you need to give the app a little (very little indeed :wink:) time to update the screen:
...
repeat with i = 1 to 1000
-- do some action here
put i into field "status"
wait 0 with messages
## as I said VERY little time :D
end repeat
...
That should do the trick.


Best

Klaus

P.S.
MetaCard still works with the LiveCode engine! 8)

Re: Display Status of a Repeat Loop

Posted: Wed Dec 15, 2010 7:04 pm
by Klaus
Addendum!

Since displaying something in a field during a repeat loop will slow down performance heavily,
you should not display EVERY number in the field. Better only display every 100th or even 1000th number!

Code: Select all

...
repeat with i = 1 to 1000
  -- do some action here
  if i mod 100 = 0 then
    put i into field "status" 
  end if
end repeat
...
You get the picture!


Best

Klaus

Re: Display Status of a Repeat Loop

Posted: Wed Dec 15, 2010 7:08 pm
by jmburnod
Caramba!

Klaus is so fast :shock:
Yes it work and the addendum is useful

Jean-Marc

Re: Display Status of a Repeat Loop

Posted: Wed Dec 15, 2010 7:16 pm
by Klaus
Yep, call me "Speedy Gonzales"! :D

Re: Display Status of a Repeat Loop

Posted: Wed Dec 15, 2010 8:37 pm
by richardmac
Awesome! Will implement immediately. Thanks for the help - I really appreciate it.