i am trying to write a small program to eject disks that have a problem un mounting. i have a pretty go idea on how to accomplish this, but i am having a problem displaying the results into a textfield (xcode, applescript studio)
on clicked theObject
if name of theObject is "quit" then
try
tell application "Eject Disk" to quit
on error
display dialog "could not quit!" buttons {"Ok"} default button 1 attached to window "main"
end try
end if
if name of theObject is "diskInfo" then
try
--display dialog (do shell script "df") buttons {"Ok"} default button 1 attached to window "main"
set theResult to do shell script "df"
set x to the offset of "up" in theResult
set theResult to (characters x thru -1 of theResult) as string
set the contents of text view "output" of window "main" to theResult
set needs display of text view "output" of window "main" to true
on error theErr
display dialog theErr
end try
end if
end clicked
i get the error can’t make characters x thru -1 of theResult and i am not really sure how to fix it.
I figured if out.
on clicked theObject
if name of theObject is "quit" then
try
tell application "Eject Disk" to quit
on error
display dialog "could not quit!" buttons {"Ok"} default button 1 attached to window "main"
end try
end if
if name of theObject is "diskInfo" then
try
set theResult to do shell script ("df " & "-t " & "hfs " & "| " & "awk " & "'{print " & "$1 " & ",$6,$7,$8,$9,$10}'")
set the contents of text field "output" of window "main" to theResult
set needs display of text field "output" of window "main" to true
on error theErr
display dialog theErr buttons {"Ok"} default button 1 attached to window "main"
end try
else if name of theObject is "run ps button" then
display panel window "running ps window" attached to window "main"
set the contents of text field "output" of window "main" to "no processes"
set needs display of text field "output" of window "main" to true
else if name of theObject is "check processes button" then
tell window of theObject
set thePS to contents of text field "running ps textfield"
set theResult to do shell script ("fstat " & "| " & "grep " & "thePS")
set the contents of text field "output" of window "main" to theResult
set needs display of text field "output" of window "main" to true
end tell
close panel window "running ps window"
else if name of theObject is "cancel" then
close panel window "running ps window"
end if
end clicked