我无法使用我的If变量来处理AppleScript

时间:2018-01-02 21:55:53

标签: macos applescript

这是我第一次使用它。我只是试图在AppleScript上创建这个时代的桌面游戏,但我似乎无法让它工作,因为它总是说它是不正确的。我是一个初学者,所以我可能做了一些愚蠢的事情:)

继承AppleScript:

display dialog "What times tables do you want the focus on?" default     answer "" buttons {"Done"} default button 1
set focusNum to the text returned of the result
set rn to random number from 1 to 12 as integer
set answer to text returned of (display dialog "What is" & space &     focusNum & space & "times" & space & rn default answer "")
set correctanswer to rn * focusNum
if correctanswer is equal to answer then
    display dialog "Correct"
else if correctanswer is not equal to answer then
    display dialog "You are Wrong :( The correct answer is " &     correctanswer buttons {"Continue"} default button 1
end if
end

任何帮助表示赞赏!

1 个答案:

答案 0 :(得分:0)

set rn to random number from 1 to 12 as integer
set answer to text returned of (display dialog "What is" 
    & space &     focusNum & space & "times" & space & rn default answer "") as integer

rn变量是一个整数,但answer是一个字符串。您需要创建两个相同类型的变量来检查它们是否相等。

相关问题