2014-01-29 72 views
0

嘿大家。我无法弄清楚我的生活。为什么我不能在这里使用'end if'?结束如果在苹果脚本

display dialog "Input your Hard Drive name *Case sensitive* 
For Example: 
Jimi 
Steve 
Jony" default answer "" 
set hdd_name to text returned of result 
set folder_name to "~/Desktop/Backup Files" 
display alert "Time Machine Extractor" message "Would you like to backup the" & folder_name & " directory now?" & return buttons {"Cancel", "Backup Now"} default button "Backup Now" 
set theButton to button returned of the result 
if theButton is "Cancel" then error number -128 
**end if** 
set shellCmd to "open /Volumes/" & quoted form of hdd_name & "/" 
set shellCopy to "cp -r " & quoted form of folder_name & " /Volumes/" & quoted form of hdd_name 
tell application "ASObjC Runner" 
    reset progress 
    set properties of progress window to {button title:"Cancel", button visible:true, message:"Backing up...", indeterminate:true} 
    activate 
    show progress 
end tell 
try 
    do shell script shellCmd 
end try 
try 
    set shellOutput to do shell script shellCopy 
end try 
tell application "ASObjC Runner" to hide progress 
display dialog "Copy Complete" 

所以,如果我有结束,如果它一直告诉我我有一个语法错误。有任何想法吗?

回答

1

您需要then

即后启动新的生产线,

if theButton is "Cancel" then 
    error number -128 
end if