0
我已经作出,其接受半径作为输入从用户和基于输入计算并显示圆的面积的简单脚本应用:简单脚本未按预期
-- initializing radius variable to some text
set radius to "Some text"
repeat until class of radius is number
-- asking user for radius
display dialog "Enter radius: " default answer "" buttons {"Done"} default button 1
set userInput to text returned of result
-- try to check if user enters radius as number
try
-- converting input from user to number
set radius to userInput as number
-- if input is found as number then below code is executed
-- obtaining radius from handler
set circleArea to calculateCircleArea(radius)
-- displaying radius and area of circle obtained to user
display dialog "Circle area for radius: " & radius & " is: " & circleArea buttons {"OK"} default button 1
end try
end repeat
-- handler definition
on calculateCircleArea(parameterRadius)
set areaOfCircle to pi * (parameterRadius^2)
end calculateCircleArea
当我执行上述脚本,并进入一些文字第一次,它再次要求我输入半径,这次我输入了一个数字,它显示了圆的区域,但它又开始要求半径作为用户的输入。
任何人都可以在上面的脚本中提示我错了吗?
感谢,
Miraaj
奏效......感谢名单:) – Devarshi 2010-11-15 12:06:03