Hi again.

This is my second dialog, and the first one that I have worked independently with.

Anyways, here it is!

__Usage:__

Right-click on any menu and click **"Temperature Converter"**, or type: **/tempcon** to open up the dialog.

Click on a temperature scale (Fahrenheit, Celsius, Kelvin) on each of the horizontal columns, which you want to convert one scale to another. (Look at top picture if you're confused)

Enter a digit into the top left edit-box, and click **"Convert!"**

Use **"Clear!"** to clear all calculations, and **"Exit!"** to exit out of the dialog.

Enjoy! :)

```
alias tempcon { dialog $iif($dialog(temperature),-v,-m) temperature temperature }
menu * {
Temperature: tempcon
}
dialog temperature {
title "Temperature Converter"
size -1 -1 150 75
option dbu
text "From:", 100, 35 3 26 10, nowrap
text "To:", 99, 105 3 26 10, nowrap
text "=", 98, 73 16 3 5, nowrap
edit "", 1, 17 11 50 10
edit "", 2, 83 11 50 10, style disable
list 3, 15 24 55 30, sort vsbar
list 4, 80 24 55 30, sort vsbar
button "Convert!", 5, 5 57 45 15
button "Clear!", 6, 100 57 45 15
button "Exit!", 7, 53 58 45 13
check "Round #'s", 8, 58 47 35 10, nowrap
}
on *:dialog:temperature:*:*: {
if ($devent == init) && ($did == 0) { did -b $dname 5-6 | did $iif($did(8).state == 1,-c,-u) $dname 8 | didtok $dname 3-4 32 Fahrenheit Celsius Kelvin }
if ($devent == sclick) {
if ($did(1).edited) && ($did(3).sel) && ($did(4).sel) { did -e $dname 5 }
if ($did == 5) {
if ($did(1) isalpha) { noop $input(You can only convert numbers!,uwok1,Error!) }
else {
var %w $did(1), %x $did(3).seltext, %y $did(4).seltext
if (%x == Fahrenheit) && (%y == Fahrenheit) { did -ra $dname 2 $iif($did(8).state == 0,%w,$round(%w,0)) }
if (%x == Fahrenheit) && (%y == Celsius) { var %z $calc((%w -32) / 1.8)) | did -ra $dname 2 $iif($did(8).state == 0,%z,$round(%z,0)) }
if (%x == Fahrenheit) && (%y == Kelvin) { var %z $calc(((%w - 32) / 1.8) + 273.15) | did -ra $dname 2 $iif($did(8).state == 0,%z,$round(%z,0)) }
if (%x == Celsius) && (%y == Celsius) { did -ra $dname 2 $iif($did(8).state == 0,%w,$round(%w,0)) }
if (%x == Celsius) && (%y == Fahrenheit) { var %z $calc((%w * 1.8) + 32)) | did -ra $dname 2 $iif($did(8).state == 0,%z,$round(%z,0)) }
if (%x == Celsius) && (%y == Kelvin) { var %z $calc(%w + 273.15) | did -ra $dname 2 $iif($did(8).state == 0,%z,$round(%z,0)) }
if (%x == Kelvin) && (%y == Kelvin) { did -ra $dname 2 $iif($did(8).state == 0,%w,$round(%w,0)) }
if (%x == Kelvin) && (%y == Fahrenheit) { var %z $calc(((%w - 273.15) * 1.8 ) + 32) | did -ra $dname 2 $iif($did(8).state == 0,%z,$round(%z,0)) }
if (%x == Kelvin) && (%y == Celsius) { var %z $calc(%w - 273.15) | did -ra $dname 2 $iif($did(8).state == 0,%z,$round(%z,0)) }
}
did -e $dname 6
}
if ($did == 6) { did -ra $dname 1-2 | did -u $dname 3-4 | did -b $dname 5-6 }
if ($did == 7) { did -u $dname 8 | dialog -x $dname }
}
if ($devent == edit) && ($did == 1) && ($did(3-4).seltext) { did $iif($did(1),-e,-b) $dname 5 }
if ($devent == close) { did -u $dname 8 }
}
```

Sign in to comment.

Let me rephrase what I said:

I meant to say using too many variables in a script can often be messy and often disorganized if not properly used; and in this case, there are really no need of using variables besides the small /var's I've included.

Completely different, lol.

Yes you are right, variables can be proven to be very useful in most situations.

Also RusselB: Thanks for the pm me you sent me ages ago; I have taken that into consideration. My apologies, I haven't sent you a reply message back.

You don'tneedit, but I just made it for the lulz.

Well, let's say your internet is out.

You can use the dialog to help you do the calculations.

Also, it's quicker than searching for a calculator on Google.

And, thanks. :P

Are you sure you want to unfollow this person?

Are you sure you want to delete this?

Click "Unsubscribe" to stop receiving notices pertaining to this post.

Click "Subscribe" to resume notices pertaining to this post.