revCopyFile Problem

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
johnmiller1950
Posts: 116
Joined: Mon Apr 30, 2007 3:33 pm

revCopyFile Problem

Post by johnmiller1950 » Wed Dec 05, 2007 12:24 pm

Greetings All,

I am writing a script (Mac OS X) that will copy multiple audio files from one folder to another. I want to use a scrollbar to show the progress when copying more than one file. I've done this with smaller text files, and it worked fine.

However, with these audio files, Revolution waits until all the files are copied, then it executes the incremental changes to the scrollbar very quickly, and all at once (bing, bing, bing). I've tried various iterations of the "wait" command right after the revCopyfile line to force a pause, but nothing seems to work.

repeat with x = 1 to (number of lines in filesXX)
set the thumbposition of scrollbar "Copy Status" to x
-- SET FILEAA
-- SET FILEBB
revcopyfile fileAA,fileBB
end repeat

Can anyone help?


Thanks!
John Miller

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Contact:

Post by Mark Smith » Thu Dec 06, 2007 4:23 am

Have you set the endValue of your scrollbar before entering the loop?

Code: Select all

set the endValue of sb "Copy Status" to the number of lines in filesXX
repeat with x = 1 to (number of lines in filesXX)
set the thumbposition of scrollbar "Copy Status" to x
-- SET FILEAA
-- SET FILEBB
revcopyfile fileAA,fileBB
end repeat
Best,

Mark

johnmiller1950
Posts: 116
Joined: Mon Apr 30, 2007 3:33 pm

Post by johnmiller1950 » Thu Dec 06, 2007 11:09 am

Mark,

Thanks for responding. Yes - the endvalue is set and the scrollbar works. It just waits until all the copies are done and then it shows all the changes at one time.

- John

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Contact:

Post by Mark Smith » Fri Dec 07, 2007 3:29 am

John, I tried this myself, and the progress bar seemed to update as I'd expect. This is the actual code I used (not substantially different from yours, I think). I added the 'put' line as another way of seeing the progress.

Code: Select all

on mouseUp
    put "/Users/marksmith/Desktop/AudioFiles/" into sFo
    put "/Users/marksmith/Desktop/Archive/" into dFo
    set the directory to sFo
    put the files into fList
    filter fList without ".*"
    
    set the endvalue of sb "prog" to the number of lines in fList
    repeat with n = 1 to the number of lines in fList
        
        set the thumbpos of sb "prog" to n
        put sFo & line n of fList into sFile
        put dFo & line n of fList into dFile
        
        put sFile & cr & dFile -- see if this shows what you'd expect
         
        revCopyFile sFile, dFile
    end repeat
    
end mouseUp
This is using 2.8.1 and 2.9 beta on OS X 10.4 macintel.

Hope we can figure it out...

Best,

Mark

johnmiller1950
Posts: 116
Joined: Mon Apr 30, 2007 3:33 pm

Post by johnmiller1950 » Fri Dec 07, 2007 4:21 pm

Mark,

Again, thanks for your response.

I duplicated your script. Mine is already pretty much the same.

I ran the script with no change in behavior.

The copies are made successfully which would indicate that the file locations are correct. However, things still don't happen in the order I would expect. First I get a spinning beach ball while the copies are being made. Then after the copies are complete. the progress bar is updated one step at a time as Mac OS X rings out the copy complete sound.

My files are MP3 files that are about 2MB each. Would this make a difference?

- John

Mark Smith
Posts: 179
Joined: Sat Apr 08, 2006 11:08 pm
Contact:

Post by Mark Smith » Sat Dec 08, 2007 4:51 am

I'd have thought the size of the files should make no difference.
My test was on a folder of WAVs, AIFs and mp3s.

You could try changing the revCopyFile for a shell call:

Code: Select all

get shell("cp" && quote & sourceFile & quote && quote & destFile & quote)
Maybe you could post the actual code?

Best,

Mark

johnmiller1950
Posts: 116
Joined: Mon Apr 30, 2007 3:33 pm

Post by johnmiller1950 » Sun Dec 09, 2007 1:58 am

Mark,

I think I found the problem. My code is embedded within a dragdrop handler, and that seems to be the problem. If I use the exact same code from within a button, everything works great.

I tried dragging different types of files that I wanted to copy and I had the same problem with all of them. The glitch seems to be using the revcopyfile inside the dragdrop handler.

I'll still do the dragdrop, but add a confirmation button. That should solve my problem.

Thanks for your interest.

- John

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

Post by Mark » Sun Dec 09, 2007 4:12 am

Hi John,

First run your script to handle the drag-and-drop. In this script, add a line

send "copyFiles" to me in 0 millisecs

Use the copyFiles handler to do everything related to copying and to set the thumbPos of the progress bar. This will work.

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

Post Reply