-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathTemperatureConverter.applescript
executable file
·52 lines (35 loc) · 2.59 KB
/
TemperatureConverter.applescript
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
--- Convert temperatures between Celsius, Fahrenheit, and Kelvin
set whichconv to choose from list {"Celsius to Fahrenheit", "Celsius to Kelvin", "Fahrenheit to Celsius", "Fahrenheit to Kelvin", "Kelvin to Celsius", "Kelvin to Fahrenheit"} with title "Convert Temperature"
set whichconv to whichconv as text
if whichconv is "Fahrenheit to Celsius" then
set ftemp to text returned of (display dialog "Convert Fahrenheit to Celsius" default answer "" buttons {"Cancel", "Convert"} default button "Convert")
set conversion1 to (ftemp - 32) * 5 / 9
set conversion1 to round conversion1
display dialog "The temperature is " & conversion1 & " Celsius" buttons {"Ok"} default button "Ok"
else if whichconv is "Celsius to Fahrenheit" then
set ftemp to text returned of (display dialog "Convert Celsius to Fahrenheit" default answer "" buttons {"Cancel", "Convert"} default button "Convert")
set conversion1 to ftemp * 9 / 5 + 32
set conversion1 to round conversion1
display dialog "The temperature is " & conversion1 & " Fahrenheit" buttons {"Ok"} default button "Ok"
else if whichconv is "Fahrenheit to Kelvin" then
set ftemp to text returned of (display dialog "Convert Fahrenheit to Kelvin" default answer "" buttons {"Cancel", "Convert"} default button "Convert")
set conversion1 to (ftemp + 459.67) * 0.5555555556
set conversion1 to round conversion1
display dialog "The temperature is " & conversion1 & " Kelvin" buttons {"Ok"} default button "Ok"
else if whichconv is "Kelvin to Fahrenheit" then
set ftemp to text returned of (display dialog "Convert Fahrenheit to Kelvin" default answer "" buttons {"Cancel", "Convert"} default button "Convert")
set conversion1 to (ftemp * 1.8) - 459.67
set conversion1 to round conversion1
display dialog "The temperature is " & conversion1 & " Fahrenheit" buttons {"Ok"} default button "Ok"
else if whichconv is "Celsius to Kelvin" then
set ftemp to text returned of (display dialog "Convert Celsius to Kelvin" default answer "" buttons {"Cancel", "Convert"} default button "Convert")
set conversion1 to (ftemp + 273.15)
set conversion1 to round conversion1
display dialog "The temperature is " & conversion1 & " Kelvin" buttons {"Ok"} default button "Ok"
else if whichconv is "Kelvin to Celsius" then
set ftemp to text returned of (display dialog "Convert Celsius to Kelvin" default answer "" buttons {"Cancel", "Convert"} default button "Convert")
set conversion1 to (ftemp - 273.15)
set conversion1 to round conversion1
display dialog "The temperature is " & conversion1 & " Celsius" buttons {"Ok"} default button "Ok"
end if
--- http://www.github.com/unforswearing