Usage: $tempconv(Number,from,to)
$tempconv(32,F,C) returns 0
$tempconv(100,C,F) returns 212
$tempconv(100,C,K) returns 373.15

Code:
alias tempconv {
  if ( ($$1 isnum) && ($regex($$2,^[cfkCFK]$)) && ($regex($$3,^[cfkCFK]$)) ) {
    if ($$2 == F) {
      if ($$3 == F) { return $$1 }
      if ($$3 == C) { return $calc(($$1 - 32) * 5 / 9) }
      if ($$3 == K) { return $calc(($$1 - 32) * 5 / 9 + 273.15) }
    }
    if ($$2 == C) {
      if ($$3 == F) { return $calc(($$1 * 9 / 5) + 32) }
      if ($$3 == C) { return $$1 }
      if ($$3 == K) { return $calc($$1 + 273.15) }
    }
    if ($$2 == K) {
      if ($$3 == F) { return $calc(($$1 - 273.15) * 9 / 5 + 32) }
      if ($$3 == C) { return $calc($$1 - 273.15) }
      if ($$3 == K) { return $$1 }
    }
  }
  echo $color(info) -esti * Error: $!tempconv called with invalid parameters }
  return
}

Last edited by Jerk; 21/06/03 05:46 AM.