Well, as I said in the other thread, I have my copying working correctly by using the cp command.
I saw the response that the button will just remained clicked until it’s handler finishes, which isn’t bad, actually.
However, I’m still stuck with my progress indicator.
tell progress indicator "myprog" of window "mywindow"
set uses threaded animation to true
set visible to true
start
end tell
do shell script "cp -R" & space & -- you get the idea :P
do shell script "cp -R" & --same as above, different directory location
tell progress indicator "myprog" of window "mywindow"
set uses threaded animation to false
set visible to false
stop
end tell
As far as I know, telling it to use the threaded animation should keep it showing even though the copy is running, but it’s apparently not…
What happens if you comment out the shell scripts and put in a delay?
-- do shell script "cp -R" & space & -- you get the idea :P
-- do shell script "cp -R" & --same as above, different directory location
delay 3
Side note: In Interface Builder, there is an option for progress indicators titled “Display when stopped” (works on OS X v10.2+).
Same result. The button remains pressed for 3 seconds while it delays, but the bar doesn’t show up. (note- it did show up when using the finder to duplicate items.)
edit- Interesting. In further testing today, I noticed that the first run of the delay did as I described above. The button remains pressed for 3 seconds, and nothing happens. However, if it is pressed a second time, the bar shows up. Odd…
bump
I’ve spent some time messing around, still with no success. Odd thing happened though.
tell progress indictator "progind"
set uses threaded animation to true
set indeterminate to true
start
end tell
delay 3
tell progress indictator "progind"
set uses threaded animation to false
set indeterminate to false
stop
end tell
Nothing happens. The button delays for 3 seconds, no progress indicator.
Oddly enough, the following example does work with the delay (the indicator does show up), but still nothing with ‘do shell script’. (I’ve had no success with that yet)
tell progress indictator "progind"
--set uses threaded animation to true (lets see what happens if the program does it)
set indeterminate to true
start
end tell
delay 3
tell progress indictator "progind"
--set uses threaded animation to false
set indeterminate to false
stop
end tell
One last bump.
I finally got this thing working. For whatever reason, the indeterminate progress bar does not work, but the spinning progress indicator does. (Set under the attributes tab in the inspector) I’m just going to use that, since it works just as well, and I have other elements that require at least OS X 10.3 to use.
Thanks for the help, though.
Er, indeterminate
is an attribute and spinning is a possible style. Did you mean to say that the bar style didn’t work for you?
Erm… Yeah, that’s what I ment. My bad.
‘Bar’ style did not work
‘Spinning’ does.
Weirdest thing in the world, but I guess ya can’t argue with results? I didn’t change the code at all, just its type in IB, and it started working. Changing it back to ‘bar’ style once again produced no results.
This is what i do when i’m using the terminal to copy something. I don’t use cp but ditto. I’ve found that more stable.
First i’ll explain what i do.
Im giving the command and say that it should run in the background and fetching de PID (process ID).
Then i basically check the size of the destination. When it’s the same as the target it’s 100%.
However this is not stable enough.
After that i’m checking if the PID is still active. When it’s not we can asume that de copy is complete.
I’m filling up the bar with an ugly trick i know. But can’t get a better one!
I’m sorry it’s in dutch but i hope you get the idea.
-- The backup command
do shell script "ditto -X /Volumes/" & HARDDISK & "/Users/" & OUDEGEBRUIKER & "/ /Volumes/'" & BACKUPLOCATIE & "'/NetInstall\\ Backup/" & NIEUWEGEBRUIKER & "/ > /dev/null 2>&1 & echo $!"
set CPPID to the result
-- the repeat for the progress bar.
repeat
try
set WAARDE to do shell script "du -ks /Volumes/'" & BACKUPLOCATIE & "'/NetInstall\\ Backup/" & NIEUWEGEBRUIKER & "| awk '{print $1}'"
set HUMANWAARDE to do shell script "du -hs /Volumes/'" & BACKUPLOCATIE & "'/NetInstall\\ Backup/" & NIEUWEGEBRUIKER & "| awk '{print $1}'"
set EENPROCENT to KBGROOTE / 100
set PROCENT to WAARDE / EENPROCENT as integer
set contents of progress indicator "laadBalk" to PROCENT
set contents of text field "inhoudLaadBalk" to "Gebruiker " & OUDEGEBRUIKER & " wordt gebackuped: " & PROCENT & "% voltooid. (" & HUMANWAARDE & " van " & HUMANGROOTE & ")."
on error
delay 0.1
end try
if KBGROOTE - WAARDE < 0 then
set KBGROOTE to WAARDE + 123
end if
-- Checking whether the proces is still running.
do shell script "ps -p " & CPPID & " | grep -v PID | awk '{print $1}'"
set PIDCHECK to the result
if CPPID = PIDCHECK then
delay 5
else
exit repeat
end if
end repeat