# Convert Temp

## Recommended Posts

Convert Temp

```MsgBox(0, "Convert Temp", ConvertTemp(80, "C", "F"))          ; ==> 176
MsgBox(0, "Convert Temp", ConvertTemp(212, "K", "Ra", 2))     ; ==> 381.6
MsgBox(0, "Convert Temp", ConvertTemp(22.7, "N", "Re", 4))    ; ==>  55.0303

Func ConvertTemp(\$D, \$F = "C", \$T = "F", \$R = 2)
\$D = (\$F = "K") ? ((\$D - 273.15)) : ((\$F = "F") ? ((\$D - 32) / 1.8) : ((\$F = "Ra") ? ((\$D + 5 / 9) - 273.15) : ((\$F = "Re") ? ((\$D * 1.25)) _
: ((\$F = "De") ? ((100 - \$D) * 2 / 3) : ((\$F = "N") ? ((\$D * 100 / 33)) : ((\$F = "Ro") ? ((\$D - 7.5) * 40 / 21) : \$D))))))
return round((\$T = "C") ? \$D : ((\$T = "K") ? ((\$D + 273.15)) : ((\$T = "F") ? ((\$D * 1.8) + 32) : ((\$T = "Ra") ? ((\$D + 273.15) * 1.8) : ((\$T = "Re") ? ((\$D * 0.8)) _
: ((\$T = "De") ? ((100 - \$D) * 1.5) : ((\$T = "N") ? ((\$D * 1 / 3)) : ((\$T = "Ro") ? ((\$D * 0.525) + 7.5) : "" ))))))), \$R)
EndFunc    ;==> ConvertTemp() AutoIt v3.3.12.0```

```ConvertTemp(Temperature in Degrees, From, To, Round by)

Celsius      --> C
Kelvin       --> K
Fahrenheit   --> F
Rankine      --> Ra
Réaumur      --> Re
Delisle      --> De
Newton       --> N
Rømer        --> Ro```
Edited by kaesereibe
##### Share on other sites

Very good friend, this shows us how AutoIt is useful in day-to-day!

Thanks for sharing,

JS

http://forum.autoitbrasil.com/ (AutoIt v3 Brazil!!!)

Somewhere Out ThereJames Ingram

Your virtual HD wherever you go, anywhere!

##### Share on other sites

`(100 - d) * 2 / 3) error`

to change

((100 - \$D) * 2 / 3)

##### Share on other sites

thx mesale0077 is fixed

.. so many \$var's o.O

##### Share on other sites

Better later than never with Ternary's in AutoIt

Edited by kaesereibe

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...