Я сделал простое приложение-скрипт, которое принимает радиус в качестве ввода от пользователя, вычисляет и отображает площадь круга на основе ввода:
-- 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