Applescript意外退出

时间:2018-10-18 13:22:08

标签: macos loops applescript

我制作了一个Applescript脚本,在其中我使用了AF重复循环来使其继续运行。循环的制作方式使我可以使用ESC(或“取消”按钮)在显示对话框或从列表框中进行选择时向后移动。

但是!!!当我从编辑器运行脚本时,“向后移动”部分可以完美地工作,但是当我将其作为应用程序运行时,它只能向后移动一半。一旦到达某个点,应用程序即会关闭。它没有给我任何崩溃报告或任何东西,它只是关闭。

循环/重复如下:

set theAction to "choose type"
set breakRepeat to false

repeat while breakRepeat is false
    if theAction is "choose type" then
        set myType to (choose from list {"Børnehaver", "Skoler"} with title "VÆLG TYPE")
        if myType is "Børnehaver" then
            set myType to "BORNEHAVER"
        else if myType is "Skoler" then
            set myType to "SKOLER"
        else if myType is false then
            try
                set myExit to (button returned of (display dialog "Vil du afslutte?" with title "Afslut?" buttons {"Annullér", "Afslut"} cancel button "Annullér" default button "Afslut"))
            on error
                set myExit to "choose type"
            end try
            if myExit is "Afslut" then
                set breakRepeat to true
            end if
        else
            set theAction to "choose year"
        end if
    else if theAction is "choose year" then
        set theYears to getfolders(alias ((myType & ":") as string), "theYears")
        set chosenYear to choosefromlist(theYears, "alias", false, -2, "VÆLG" & space & myType & "-år", "Vælg skoleår:")
        if chosenYear is false then
            set theAction to "choose type"
        else
            set theAction to "choose school"
        end if
    else if theAction is "choose school" then
        set theSchools to getfolders(chosenYear, "theSchools")
        set chosenSchool to choosefromlist(theSchools, "alias", false, -2, "VÆLG SKOLE:", "Vælg skole:")
        if chosenSchool is false then
            set theAction to "choose year"
        else
            set theAction to "choose UID"
        end if
    else if theAction is "choose UID" then
        try
            set chosenUID to searchjpgs(chosenSchool)
            set chosenUIDfiles to choosefromlist(chosenUID, "alias", false, -1, "VÆLG FIL:", "Vælg fil:")
            if chosenUIDfiles is false then
                set theAction to "choose school"
            else
                set theAction to "info for file"
            end if
        on error
            set theAction to "choose school"
        end try
    else if theAction is "info for file" then
        set theAction to fileinfo(chosenUIDfiles)
    else if theAction is "build package" then
        set chosenPackages to buildpackage(mypackages, chosenUIDfiles)
        if chosenPackages is false then
            set theAction to "choose UID"
        else
            makeprintfiles(chosenUIDfiles, chosenPackages)
            set theAction to "choose UID"
        end if
    end if
end repeat

0 个答案:

没有答案