2012-06-10 38 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