Celcius => Fahrenheit conversion - 21/06/03 03:02 AM
Can someone give me steps as to how I would make an alias for this?
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 }
Alias temp { var %t = $left($1,-1) var %s = $right($1,1) if (F == %s) { return $1 ( $+ $round($calc((%t - 32) / 1.8),2) $+ C $+ ) } if (C == %s) { return $1 ( $+ $round($calc((%t * 1.8) + 32),2) $+ F $+ ) } if (K == %s) { return $1 ( $+ $round($calc(%t - 273.15),2) $+ C $+ ) ( $+ $round($calc(((%t - 273.15) * 1.8) + 32),2) $+ F $+ ) } }
ALIAS Therm { var %n = $$1, %in = $$2, %out = $$3 if ( %in == F ) var %in = C, %n = $calc((%n - 32) * 0.555556 if ( %in == C ) var %n = $calc(%n - 273.15) if ( %out == K) return %n var %n = $calc(%n + 273.15) if ( %out == C ) return %n var %n = $calc(%n * 1.8 + 32) return %n }