Applescript 苹果书中的结局

Applescript 苹果书中的结局,applescript,Applescript,大家好。我一辈子都搞不懂这个。为什么我不能在这里使用“如果结束” 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 Mach

大家好。我一辈子都搞不懂这个。为什么我不能在这里使用“如果结束”

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"

因此,如果它一直告诉我有一个语法错误,那么我就有了结尾。有什么想法吗?

你需要在
之后开始一行新的内容,然后

i、 e

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