Temperature Converter — File Browser

TemperatureConverterv1.1 / TemperatureConverterv1.1 / Temp-converter / Tempconverter.mrc

Tempconverter.mrc — 5.26 KB — Download this file

; Syntax: $temp(N,type1,type2)
alias temp {
  var %echo echo $color(info) -a * $!temp $+ :
  if $1 !isnum { %echo $1 is not a number. | halt }
  if $len($2) > 2 { %echo $2 is not a valid temperature unit. | halt }
  if $len($3) > 2 { %echo $3 is not a valid temperature unit. | halt }
  if $2 == c { var %c = $1 }
  elseif $2 == f { var %c = $calc(($1 -32)*(5/9)) }
  elseif $2 == re { var %c = $calc($1 *1.25) }
  elseif $2 == ra { var %c = $calc(($1 -491.67) /1.8) }
  elseif $2 == k { var %c = $calc($1 -273.15) }
  if $3 == c { return $round(%c,2) $+ ° Celsius }
  elseif $3 == f { return $round($calc((%c *(9/5)) +32),2) $+ ° Fahrenheit }
  elseif $3 == re { return $round($calc(%c *(4/5)),2) Réaumur }
  elseif $3 == ra { return $round($calc(((%c *(9/5)) +32 +459.67)),2) Rankine }
  else { return $round($calc(%c +273.15),2) Kelvin }
}

menu channel,query,menubar {
  -
  Temp Converter $ver
  .Temp Converter:otemp
  .$iif(!$isfile($+(",$scriptdirtemp-readme.txt,")),$style(2)) Readme: run $+(",$scriptdirtemp-readme.txt,")
  .-
  .About:dialog $iif($dialog(temp-about),-v,-m temp-about) temp-about
  .-
  .Unload:if $input(Are you sure you want to unload this $crlf $+ Temperature Converter?,yw,Unload Script?) { .unload -rs $+(",$script,") }
}

dialog temp {
  title "Temperature Converter"
  size -1 -1 133 102
  option dbu
  box "Convert from:", 1, 2 2 62 70
  edit "", 2, 4 11 58 10, center
  radio "Celsius", 3, 7 21 28 10, group
  radio "Fahrenheit", 4, 7 31 36 10
  radio "Kelvin", 5, 7 41 50 10
  radio "Rankine", 6, 7 51 50 10
  radio "Réaumur", 7, 7 61 50 10
  box "Convert to:", 8, 68 2 62 70
  edit "", 9, 70 11 58 10, center read
  radio "Celsius", 10, 74 21 28 10, group
  radio "Fahrenheit", 11, 74 31 36 10
  radio "Kelvin", 12, 74 41 50 10
  radio "Rankine", 13, 74 51 50 10
  radio "Réaumur", 14, 74 61 50 10
  button "Convert", 15, 3 73 37 12, flat
  button "Close", 16, 92 73 37 12, flat ok cancel
  button "Message to:", 17, 3 87 37 12, flat
  combo 18, 42 88 60 50, edit size drop
  menu &File,20
  item &Readme,30
  item &About,50
}

on *:DIALOG:temp:*:*: {
  if $devent == init {
    var %i = 1
    while $chan(%i) { did -a $dname 18 $chan(%i) | inc %i }
    if !%temp.1 { set %temp.1 3 }
    if !%temp.2 { set %temp.2 11 }
    did -c $dname %temp.1
    did -c $dname %temp.2
    if %temp.22 != $null { did -a $dname 2 %temp.22 }
    if %temp.99 != $null { did -a $dname 9 %temp.99 }
  }
  if $devent == sclick {
    if $istok(3 4 5 6 7,$did,32) { set %temp.1 $did }
    if $istok(10 11 12 13 14,$did,32) { set %temp.2 $did }
    if $istok(3 4 5 6 7 10 11 12 13 14,$did,32) && $did(2) != $null { did -ra $dname 9 $temp($did(2),$type(%temp.1),$type(%temp.2)) }
    if $did == 15 && $did(2) != $null { did -ra $dname 9 $temp($did(2),$type(%temp.1),$type(%temp.2)) | did -f $dname 2 }
    if $did == 17 && $did(18) {
      if $($did(18),2) == Status Window { echo -s $did(2) $did(%temp.1) is $did(9) | did -f $dname 2 }
      else msg $($did(18),2) $did(2) $did(%temp.1) is $did(9) | did -f $dname 2
    }
  }
  if $devent == menu {
    if $did == 30 { run $+(",$scriptdirtemp-readme.txt,") }
    if $did == 31 { dialog -c $dname }
    if $did == 50 { dialog $iif($dialog(temp-about),-v,-m temp-about) temp-about }
  }
  if $devent == close {
    unset %temp.dis
    if $did(2) { set %temp.22 $did(2) }
    if $did(9) { set %temp.99 $did(9) }
  }
}

alias otemp { dialog $iif($dialog(temp),-v,-m temp) temp }
alias -l ver { return v1.1 }
alias -l author { return SSJ4_Son_Goku }
alias type { 
  if $istok(3 10,$1,32) { return c }
  elseif $istok(4 11,$1,32) { return f }
  elseif $istok(5 12,$1,32) { return k }
  elseif $istok(6 13,$1,32) { return ra }
  else { return re }
}

dialog -l temp-about {
  title "About"
  size -1 -1 96 62
  option dbu
  text by $author, 1, 26 10 46 8, center
  text "Temperature Converter v1.0", 2, 17 1 70 8
  link "benmanderson@yahoo.com", 3, 21 36 67 8
  text "Email:", 4, 3 36 14 8
  text "Made on January 25", 5, 25 20 49 8
  ;button "Readme", 6, 2 49 37 12
  button "Ok", 7, 33 47 37 12, ok
}


on *:DIALOG:temp-about:init:*: { if !$isfile($+(",$scriptdirtemp-readme.txt,")) { did -b $dname 6 } }
on *:DIALOG:temp-about:sclick:*: { 
  if $did == 3 { run mailto:benmanderson@yahoo.com }
  ;if $did == 6 { run $+(",$scriptdirtemp-readme.txt,") }
}

on *:UNLOAD:{
  echo -s Thx for using Temperature Converter $+ $ver by $author
  echo -s If you have any suggestions or complaints, I'd love to here about it.
  echo -s My email is: benmanderson@yahoo.com
  echo -s Unloading script...
  unset %temp.*
  echo -a Script unloaded. | echo -s Script unloaded.
}
on *:LOAD:{
  if $version <= 6.03 {
    echo -s This script may have some errors with version $version $+ .
    echo -s If you do have problems with this script please upgrade your mIRC to the newest version @ www.mirc.co.uk
  }
  echo -s Thx for downloading this script.
  var %a = To use this script say /otemp
  echo -a %a | echo -s %a
}

/*
on $*:TEXT:m/^!temp(erature)?/iS:#: {
  if %temp.flood { halt }
  else set -u10 %temp.flood 1
  var %a = m/^(-?\d+(?:\.\d+)?)([kcf]|r[ae])\s+to\s+([kcf]|r[ae])$/i,%b,%c
  if $regex(temp,$2-,%a) { msg $chan $2 is $temp($regml(temp,1),$regml(temp,2),$regml(temp,3)) }
}
*/