首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何修复语法错误:期望的行尾等,但在applescript中找到脚本的末尾?

如何修复语法错误:期望的行尾等,但在applescript中找到脚本的末尾?
EN

Stack Overflow用户
提问于 2012-06-11 00:10:50
回答 2查看 10.4K关注 0票数 1

我正在为我的世界创建一个Mod安装程序,这是只为Mac。它使用多个应用程序分别完成一项任务(每个应用程序都是一个applescript应用程序)。但今天我开始做一个能做所有事情的应用程序。当我完成脚本并试图编译它时,出现语法错误:预期的行尾等,但找到脚本的末尾。我想我做的一切都是对的,但是我不知道是什么导致了这个问题。代码如下:

代码语言:javascript
复制
say "You are running iCraft version one point one for minecraft version 1.2.5"
display dialog "Which tool do you want to use?" buttons {"Mod Installer", "Backup", "Restore"} default button 3
set the button_pressed to the button returned of the result 
    if the button_pressed is "Mod Installer" then
        do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/installer.sh"
            display dialog "Insert all mod files into the Mods folder."
            display dialog "Have you inserted all Mod files into the Mods folder?" buttons {"Yes", "No"} default button 2
                    if the button_pressed is "Yes" then
                        do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/installer2.sh"
                                display dialog "Finished"
                        else
                            display dialog "Insert mod files into the Mods folder and restart iCraft.app."
                        end if
if the button_pressed is "Backup" then
    display dialog "Are you sure you want to backup your Minecraft.jar in it's current state?" buttons {"Yes", "No"} default button 2                       
            if the button_pressed is "Yes" then
                    do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/backup.sh"
                            display dialog "Finished, find it in your Backups directory in the iCraft folder"
            else
                display dialog "Backup aborted"             
            end if
else
    display dialog "Are you sure you want to restore your Minecraft.jar with your backup?" buttons {"Yes", "No"} default button 2
            if the button_pressed is "Yes" then
                do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/restore.sh"
                        display dialog "Restore finished"
            else
                display dialog "Restore aborted"            
end if
end
EN

回答 2

Stack Overflow用户

发布于 2012-06-11 00:22:25

最后一个end if实际上是缩进的if的结尾,留下外部if没有end if。或者反之亦然,不管你怎么看它。

换句话说,在最后一行之前添加另一个end if

票数 2
EN

Stack Overflow用户

发布于 2014-02-21 00:56:16

这将会起作用:

代码语言:javascript
复制
say "You are running iCraft version one point one for minecraft version 1.2.5"
display dialog "Which tool do you want to use?" buttons {"Mod Installer", "Backup", "Restore"} default button 3
set the button_pressed to the button returned of the result
if the button_pressed is "Mod Installer" then
    do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/installer.sh"
    display dialog "Insert all mod files into the Mods folder."
    display dialog "Have you inserted all Mod files into the Mods folder?" buttons {"Yes", "No"} default button 2
    if the button_pressed is "Yes" then
        do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/installer2.sh"
        display dialog "Finished"
    else
        display dialog "Insert mod files into the Mods folder and restart iCraft.app."
    end if
    if the button_pressed is "Backup" then
        display dialog "Are you sure you want to backup your Minecraft.jar in it's current state?" buttons {"Yes", "No"} default button 2
        if the button_pressed is "Yes" then
            do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/backup.sh"
            display dialog "Finished, find it in your Backups directory in the iCraft folder"
        else
            display dialog "Backup aborted"
        end if
    else
        display dialog "Are you sure you want to restore your Minecraft.jar with your backup?" buttons {"Yes", "No"} default button 2
        if the button_pressed is "Yes" then
            do shell script "~/desktop/iCraft/iCraft.app/contents/resources/scripts/restore.sh"
            display dialog "Restore finished"
        else
            display dialog "Restore aborted"
        end if
    end if
end if
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/10970207

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档