我制作了一个应该可以工作的计算器,但却没有。唯一有效的部分是增加。这是我的代码:
awe.projections.add({
id:'n',
geometry:{ path:'cube.obj'},
rotation:{ x:30, y:30, z:0 },
material:{
type: 'phong',
color:0x000000,
},
}, { poi_id: 'north' });
这是一个AppleScript代码。如果这是一个不起眼的问题,我很抱歉,但我需要帮助。谢谢!
答案 0 :(得分:0)
您使用三个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