this is a basic conversion program written on applescript for inclusion into alfred.
call up alfred, and type
convert 30 ft to m
or
convert 30 m to ft
this can be easily extended by adding your own variables.
on alfred_script(q)
--display dialog q
-- set for when running from applescript
-- set q to "30 ft to m"
set Feet2Meters to 0.3048
set Meters2Feet to 3.2808399
--find first occurance of unit
set max_args to number of q
if max_args = 1 then
set number1 to ( q)
if number1 = "?"
display dialog "Help\nConversion ft to m"
exit
end if
else
set number1 to (word 1 of q)
set unit1 to (word 2 of q)
--set number2 to (word 3 of q)
set unit2 to (word 4 of q)
end if
-- display dialog "1: " & number1 & ", 2:" & unit1 & ", 3:" & unit2
if unit1 = "ft" then
if unit2 ="m" then
set conversion to Feet2Meters
end if
end if
if unit1 = "m" then
if unit2 = "ft" then
set conversion to Meters2Feet
end if
end if
set final to number1 * conversion
-- display dialog final
display dialog "Conversion: " & number1 & " " & unit1 & " is " & final & " " & unit2
end alfred_script
call up alfred, and type
convert 30 ft to m
or
convert 30 m to ft
this can be easily extended by adding your own variables.
on alfred_script(q)
--display dialog q
-- set for when running from applescript
-- set q to "30 ft to m"
set Feet2Meters to 0.3048
set Meters2Feet to 3.2808399
--find first occurance of unit
set max_args to number of q
if max_args = 1 then
set number1 to ( q)
if number1 = "?"
display dialog "Help\nConversion ft to m"
exit
end if
else
set number1 to (word 1 of q)
set unit1 to (word 2 of q)
--set number2 to (word 3 of q)
set unit2 to (word 4 of q)
end if
-- display dialog "1: " & number1 & ", 2:" & unit1 & ", 3:" & unit2
if unit1 = "ft" then
if unit2 ="m" then
set conversion to Feet2Meters
end if
end if
if unit1 = "m" then
if unit2 = "ft" then
set conversion to Meters2Feet
end if
end if
set final to number1 * conversion
-- display dialog final
display dialog "Conversion: " & number1 & " " & unit1 & " is " & final & " " & unit2
end alfred_script
No comments:
Post a Comment