Page 1 of 1

revCopyFile Problem

Posted: Wed Dec 05, 2007 12:24 pm
by johnmiller1950
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

Posted: Thu Dec 06, 2007 4:23 am
by Mark Smith
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

Posted: Thu Dec 06, 2007 11:09 am
by johnmiller1950
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

Posted: Fri Dec 07, 2007 3:29 am
by Mark Smith
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

Posted: Fri Dec 07, 2007 4:21 pm
by johnmiller1950
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

Posted: Sat Dec 08, 2007 4:51 am
by Mark Smith
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

Posted: Sun Dec 09, 2007 1:58 am
by johnmiller1950
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

Posted: Sun Dec 09, 2007 4:12 am
by Mark
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