applescript计算器不工作
我做了一个计算器,它应该能用,但不能用。唯一有效的部分是加法。这是我的代码:applescript计算器不工作,applescript,calculator,Applescript,Calculator,我做了一个计算器,它应该能用,但不能用。唯一有效的部分是加法。这是我的代码: my Calculator() on Calculator() display dialog "Calculator" buttons {"Add", "Multiply", "Divide"} if button returned of the result is "Add" then display dialog "What plus What?" default answer
my Calculator()
on Calculator()
display dialog "Calculator" buttons {"Add", "Multiply", "Divide"}
if button returned of the result is "Add" then
display dialog "What plus What?" default answer ""
set a to (text returned of result)
if a is equal to "q" then
return
end if
display dialog "Next number" default answer ""
set b to (text returned of result)
set c to a + b
display dialog "The answer is " & c buttons {"Start Again", "Quit"}
if button returned of the result is "Quit" then
return
else
my Calculator()
end if
end if
if button returned of the result is "Multiply" then
display dialog "What times what?" default answer ""
set a to (text returned of result)
if a is equal to "q" then
return
end if
display dialog "Next number" default answer ""
set b to (text returned of result)
set c to a * b
display dialog "The answer is " & c buttons {"Start Again", "Quit"}
if button returned of the result is "Quit" then
return
else
my Calculator()
end if
end if
if button returned of the result is "Divide" then
display dialog "What divided by what?" default answer ""
set a to (text returned of result)
if a is equal to "q" then
return
end if
display dialog "Next number" default answer ""
set b to (text returned of result)
set c to a / b
display dialog "The answer is " & c buttons {"Start Again", "Quit"}
if button returned of the result is "Quit" then
return
else
my Calculator()
end if
end if
end Calculator
end
end
这是一个applescript代码。如果这是一个问题,我很抱歉,但我需要帮助。谢谢 您使用三个
if/end if
语句来处理返回的按钮,您应该只使用一个if/end
,并在两者之间使用else if
。我已经编辑了你的代码来修复它,并注释掉了不正确的区域
e、 g:
谢谢,这就解决了。抱歉,我拒绝了编辑,我没有注意到更改
my Calculator()
on Calculator()
display dialog "Calculator" buttons {"Add", "Multiply", "Divide"}
if button returned of the result is "Add" then
display dialog "What plus What?" default answer ""
set a to (text returned of result)
if a is equal to "q" then
return
end if
display dialog "Next number" default answer ""
set b to (text returned of result)
set c to a + b
display dialog "The answer is " & c buttons {"Start Again", "Quit"}
if button returned of the result is "Quit" then
return
else
my Calculator()
end if
else if button returned of the result is "Multiply" then
display dialog "What times what?" default answer ""
set a to (text returned of result)
if a is equal to "q" then
return
end if
display dialog "Next number" default answer ""
set b to (text returned of result)
set c to a * b
display dialog "The answer is " & c buttons {"Start Again", "Quit"}
if button returned of the result is "Quit" then
return
else
my Calculator()
end if
else if button returned of the result is "Divide" then
display dialog "What divided by what?" default answer ""
set a to (text returned of result)
if a is equal to "q" then
return
end if
display dialog "Next number" default answer ""
set b to (text returned of result)
set c to a / b
display dialog "The answer is " & c buttons {"Start Again", "Quit"}
if button returned of the result is "Quit" then
return
else
my Calculator()
end if
end if
end Calculator
end
end