Hello - I'm trying to make a progress scrollbar go for 4 seconds and then show a Start button. The thumbPos goes to 40 then stops and in 4 seconds the Start button shows but with no visual effect. This worked at home on my PC but not at work on my Mac : /
I'm on LC 6.6.0
on preopencard
hide button "start"
set the thumbposition of scrollbar "splashScrollbar" to 20
end preopencard
on opencard
wait 1 second
set the thumbposition of scrollbar "splashScrollbar" to 40
wait 1 second
set the thumbposition of scrollbar "splashScrollbar" to 60
wait 1 second
set the thumbposition of scrollbar "splashScrollbar" to 80
wait 1 second
set the thumbposition of scrollbar "splashScrollbar" to 100
lock screen for visual effect
hide scrollbar "splashScrollbar"
hide field "load"
show button "start"
unlock screen with visual effect dissolve
end opencard
on closecard
show scrollbar "splashScrollbar"
show field "load"
end closecard
Progress Scrollbar
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Progress Scrollbar
On OS X LC often draws faster than the rendering interrupt with show. You can correct for this by adding this line wherever you need a visual update that isn't happening:
wait 0 with messages
wait 0 with messages
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: Progress Scrollbar
Hi roddy,
In an effort to wean beginners away from "wait" (it's bad because it blocks up the engine) I 'd like to show you "send".
Nice and smooth huh?
But it's not how smooth it is that's important, in those 10 milliseconds the engine is free to get on with other tasks. In those 10 milliseconds it can sort a list of 10,000 names alphabetically.
Of course you are not doing that but it can update the scrollbar.
Simon
In an effort to wean beginners away from "wait" (it's bad because it blocks up the engine) I 'd like to show you "send".
Code: Select all
on preopencard
hide button "start"
set the thumbposition of scrollbar "splashScrollbar" to 0
goScroll
end preopencard
local x
on goScroll
add 1 to x
if x >= 400 then
lock screen for visual effect
hide scrollbar "splashScrollbar"
hide field "load"
show button "start"
unlock screen with visual effect dissolve
exit goScroll
end if
set the thumbposition of scrollbar "splashScrollbar" to x/4
send goScroll to me in 10 millisec --here is the magic
end goScroll
But it's not how smooth it is that's important, in those 10 milliseconds the engine is free to get on with other tasks. In those 10 milliseconds it can sort a list of 10,000 names alphabetically.
Of course you are not doing that but it can update the scrollbar.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Progress Scrollbar
Thank you Simon, very cool.
-
- VIP Livecode Opensource Backer
- Posts: 10052
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: Progress Scrollbar
I don't think "wait" is necessarily bad, any more than global variables are "bad" even though some folks characterize them as such despite most languages supporting them. Each language feature has a place, so it's good to be familiar with the tradeoffs with them so you can choose the best fit for the task at hand.Simon wrote:In an effort to wean beginners away from "wait" (it's bad because it blocks up the engine) I 'd like to show you "send".
"Wait" by itself does indeed block the flow of execution in the engine, but "0" reduce the duration to the amount of time it takes for the OS to process its event loop once, and "with messages" allows LC to handle messages triggered by other user interactions in the meantime.
With both "wait" and "send", idle plays a role, but in different, almost opposite, ways: "wait" often results in faster execution because the loop doesn't surrender control to idle until "wait" is explicitly called, while events handled by "send" are only processed at idle time.
Sometimes blocking execution is useful, but other times simulating threads can be useful. With LC's rich variety of syntax, we can have either as the task at hand requires.
Some time ago I put together a simple demonstration of simulated threading techniques for my local user group, and since it contains both "wait" and "send" forms it may be useful in exploring options here:
http://fourthworld.net/channels/lc/IdleHour.rev
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn