System progress bar

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Stormy1
Posts: 31
Joined: Tue Jul 14, 2009 1:47 pm

System progress bar

Post by Stormy1 » Fri Aug 07, 2009 11:51 am

Hi Everyone (again!)

I have a quasi installer stack which simply asks the user to select a location for a folder and then my script copies the folder from the cdrom into that location.

It all works fine however since the folder is around 350Mb, I wondered if its possible to get a copy progress bar up to show the user that something is happening. Is this possible as an OS thing or do I need to build a card with a progress bar?

My script at the moment is as follows:

On mouseUp
answer folder "Please select a location to save the folder to."
if it is empty then exit mouseUp
put it into tDestinationFolder
revCopyFolder "/folder",tDestinationFolder
pass mouseUp
end mouseUp

Thanks as always

shadowslash
Posts: 344
Joined: Tue Feb 24, 2009 6:14 pm
Contact:

Post by shadowslash » Fri Aug 07, 2009 12:54 pm

Hi Stormy1,

That would require some time. You need time to code it so that it copies the files one by one into a destination folder and not the whole folder being copied altogether. That way, you can set the endValue property of your loading bar to the number of files that needs to be "installed". Then every time a file gets copied, you simply add 1 to the current thumbPos property of your loading bar.
Parañaque, Philippines
Image
Image

Stormy1
Posts: 31
Joined: Tue Jul 14, 2009 1:47 pm

Post by Stormy1 » Fri Aug 07, 2009 1:11 pm

Thanks shadowslash

But isn't there a way to tell Windows and MacOS to show its own progress bar as it would any copying of folders normally?

If the revCopyFolder is able to copy all the files and subfolders within it without having to specify every file, can't this drive a progress bar itself?

Thanks

shadowslash
Posts: 344
Joined: Tue Feb 24, 2009 6:14 pm
Contact:

Post by shadowslash » Fri Aug 07, 2009 1:14 pm

Stormy1 wrote:Thanks shadowslash

But isn't there a way to tell Windows and MacOS to show its own progress bar as it would any copying of folders normally?

If the revCopyFolder is able to copy all the files and subfolders within it without having to specify every file, can't this drive a progress bar itself?

Thanks
For Windows I think you may need to hook to a system DLL to do that. I'm not just certain which it should be. For Mac, I got no idea.since I don't have it yet.
Parañaque, Philippines
Image
Image

Stormy1
Posts: 31
Joined: Tue Jul 14, 2009 1:47 pm

Post by Stormy1 » Mon Aug 10, 2009 2:46 pm

Hiya

Could someone let me know where I should look in order to get Revolution to provide a copy progress for what I'm trying to do?

The user has two folders on a cdrom. I have a little stack installer (autoruns from the cdrom) which asks them for the destination and then via revCopyFolder, it copies either folder to the location. This all works fine.

However, since the folders are around 200Mb each, it would be great to have a progress bar showing that the machine is doing something!

I know it involves a repeat of some kind and thumbPos but can't find anything in the documentation as to how to do this.

Many thanks

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Mon Aug 10, 2009 4:53 pm

Hi Stormy,

I have created an installer with all features one would expect from such an installer, including a progress bar to indicate the amount of files copied.

I ditched the revCopyFile and revCopyFolder commands, because they block Revolution entirely. As soon as you call one of these commands, Revolution stays unresponsive until it finsihes copying.

Instead, you should use a repeat loop, which copies parts of the files, e.g. one MB at a time.

Create a scrollbar, set the startValue to 0 and the endValue to 100.

First, calculate the total file size from the detailed files (see docs). Then use a variable to count how many data have been read and set this to 0. Read the first chunk, write it to the destination, update the counter and calculate progress in %. Set the thumbPos of the progress bar to the percentage value. Read the next chunk, write it, update counter, update progress bar, et cetera, until you have read the entire file.

You could use another progress bar to display the number if files that have been copies already. You might want to disregard the first progress bar for files smaller than a few KB, to speed up the process. Make sure no to update the progress bar if the percent value isn't different, because redrawing the progress bar takes time.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Stormy1
Posts: 31
Joined: Tue Jul 14, 2009 1:47 pm

Post by Stormy1 » Wed Aug 12, 2009 3:58 pm

Hi Mark

Can I not say... if the revCopyFolder is done, show a window?

I tried this:
if revCopyFolder is done then
answer "The folder has finished copying" with "OK"
if it is "OK" then quit
end if

Didn't work though although I didn't get any script errors.

So in other words, could I get round this by bring up a window once revCopyFolder is finished?

Thanks

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Wed Aug 12, 2009 4:09 pm

Hi Stormy1,

That doesn't make sense. A user isn't interested in knowing when something is done, but in whether he's waiting because the computer is still copying or because the software has crashed. You need to show something alive on the screen while your script is still copying.

If you try to follow my instructions in my earlier post, you can just let me know where you get stuck.

Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

SparkOut
Posts: 2943
Joined: Sun Sep 23, 2007 4:58 pm

Post by SparkOut » Wed Aug 12, 2009 4:10 pm

If you want to get away without showing a progress meter as suggested by Mark (which is the best way) then you could always just fudge a method of letting the user know that work is in progress as in something like:

Code: Select all

   set the visible of image "PleaseWaitAnimatedGif" to true
   lock cursor
   set the cursor to watch
   revCopyFolder tSourcePath,tDestinationPath
   set the visible of image "PleaseWaitAnimatedGif" to false
   answer "done"
   unlock cursor
If the (Windows) hourglass appears for a long time, with no other indication of progress/activity though, a typical user thinks that it has stopped and needs to be clicked on again, or has crashed and will exit. So a "proper" progress meter is best.

Stormy1
Posts: 31
Joined: Tue Jul 14, 2009 1:47 pm

Post by Stormy1 » Wed Aug 12, 2009 5:46 pm

Thanks Mark
I agree and you're right, I do need to learn this. I'm still getting to grips with coding in Rev for more complex things but as always, I have time constraints especially with this current project.

Hence, SparkOut, your little work around has helped fill this gap.

Thank you both.

Post Reply