Progress Bars

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
Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Progress Bars

Post by Traxgeek » Mon Feb 16, 2015 11:14 pm

Hi,
I'm trying to let myself know that the app I'm creating is in fact doing something long-winded / is not stalled - and I came up with both the busy indicator and the progress bar. Generally simple stuff but I'm now lost'... again !

Both the busy indicator and the progress bar work when the engine isn't completely tied up... by that I mean, for example, transferring multiple files from one place to another or deleting multiple files. In both cases I use a repeat structure and insert a 'wait 0 milliseconds with messages' command within the repeat structure (between each transfer or delete operation) to ensure that any waiting messages (like updating a 'progress bar') are handled. The end result is that I see something going on whilst a long-winded process is 'hogging' resources... All well and good... until...
One of my files is a ZIP file (created by my app with a progress bar), all well and good. Once the ZIP file is created it can be optionally copied to some other location.
The ZIP file (today) has exceeded 200MB in size (contains multiple picture images etc) and during the copy process (which can take up to 40 seconds) I note the busy indicator / progress bar stalls / halts for the duration of the copy... which can cause concern... and my Android ICS device to produce a warning "...stopped responding' message... Yuch - ugly !

So, to my question :
Is there a way to copy a large (in my case ZIP) file from one place to another whilst having a progress bar / busy indicator update ? I did see somewhere that with a text file one can (effectively) use a repeat structure to copy chunks (say 1KB) of data from a large file to a new location until an 'EOF' is encountered...
Can one do this with a ZIP file and is there an example - I can't find where I found this method / example in the past...

Thanks a mil. Much appreciated.
Regards
Trax
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Progress Bars

Post by Klaus » Tue Feb 17, 2015 6:19 pm

Hi Trax,

since a ZIP file is just binary data, you can use the long "open file xyz" syntax.
Don't have the correct syntax at hand so I will use a mixture of real and pseudocode, but you get the picture :D

Code: Select all

...
put "path to/sourcefile.zip" into tSource
put "path to/destinationfile.zip" into tDest
open file tSource for binary read
open file tDest for binary write

## Now read and write small chuncks of data:
repeat until EOF --???
  ## Not sure if that is correct, please check the dictionary :-)

  read from file tSource for X 
  ## where X is the number of chars/bytes you want "copy" to tDest

  write IT to file tDest
  ## Update your progressbar here and now
end repeat
close file tSource
close file tDest
...
Best

Klaus

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: Progress Bars

Post by Traxgeek » Thu Feb 19, 2015 7:27 pm

Thanks Klaus,

Would you happen to know whether this method work for ANY file type/extension or are there limitations ?
Once again, thanks a million - really appreciated.
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Progress Bars

Post by Klaus » Thu Feb 19, 2015 8:13 pm

Hi Trax,

that will work for ANY filetype! :D
But use "... for text read" etc. when accessing text files.


Best

Klaus

Traxgeek
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 281
Joined: Wed Jan 09, 2013 10:11 am

Re: Progress Bars

Post by Traxgeek » Mon Feb 23, 2015 9:47 am

Thanks a million Klaus. Much appreciated.
Regards.
Trax
I'm 'getting there'... just far too slowly !
Mac (Siera) and PC (Win7)
LiveCode 8.1.2 / 7.1.1

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”