2012-06-10 64 views
1

我正在为仅适用于Mac的Minecraft创建Mod安装程序。它使用多个应用程序每个执行一项任务(每个都是一个applescript应用程序)。但是今天我开始制作一款可以完成所有工作的应用当我完成脚本并尝试编译时,它给了我语法错误:预计行结束等,但发现脚本结束。 我想我有一切权利,但我不知道是什么原因造成的。 下面是代码:如何解决语法错误:预计行结束等,但发现在脚本的脚本结束?

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 

回答

2

最后end if实际上结束了真实缩进if,留下外if没有end if。反之亦然,但是你想看看它。

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

+0

你,先生,是史诗。谢谢! – user1447526

+1

@ user1447526:为了最好地感谢本网站上的答案可解决您的问题的人,您可以通过点击答案旁边的绿色复选标记来接受答案。 –

1

这将工作:

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