All pastes #485161 Raw Edit

Mine

public text v1 · immutable
·published 2007-05-12 22:01 UTC
rendered paste body
;############################ 
;#####CALCULATOR DIALOG###### 
;############################ 

dialog calc { 
  title "Calculator" 
  size -1 -1 97 42 
  option dbu 
  edit "", 1, 7 11 81 10, autohs 
  box "Formula", 2, 2 2 91 24 
  button "Calc", 3, 10 27 37 12 
  button "Clear", 4, 47 27 37 12 
} 
on *:TEXT:!calc *:#:{ var %a = $replace($2-,m,000000,k,000) | msg $chan %a = $calc(%a) }
on *:DIALOG:calc:sclick:3:{ did -ra calc 1 $acalc($did(calc,1)) } 
on *:DIALOG:calc:sclick:4:{ did -r calc 1 } 
alias acalc { 
  tokenize 32 $remove($1-,$chr(44),$chr(32)) 
  var %matches $regex($1-,/L(\d\d?)/gi), %i = 1, %calculate = $1- 
  while (%i <= %matches) { 
    var %calculate = $replace(%calculate,L $+ $regml(%i),$LevelsAndXp($regml(%i))) 
    inc %i 
  } 
  if (k isin %calculate) { 
    var %x = 1, %total = $pos(%calculate,k,0) 
    while (%x <= %total) { 
      var %kpos = $pos(%calculate,k,%x), %kstartpos = $calc(%kpos - 1), %klen = 1 
      while ($mid(%calculate,%kstartpos,1) isin 1234567890.) && (%kstartpos > 0) { 
        dec %kstartpos 
        inc %klen 
      } 
      var %calculate = $iif(%kstartpos >= 0,$left(%calculate,%kstartpos)) $+ $chr(40) $+ $mid(%calculate,$calc($iif(%kstartpos == 0,0,%kstartpos +1)),%klen) $+ $chr(41) $+ $right(%calculate,- $+ %kpos) 
      inc %x 
    } 
  } 
  if (m isin %calculate) { 
    var %x = 1, %total = $pos(%calculate,m,0) 
    while (%x <= %total) { 
      var %mpos = $pos(%calculate,m,%x), %mstartpos = $calc(%mpos - 1), %mlen = 1 
      while ($mid(%calculate,%mstartpos,1) isin 1234567890.) && (%mstartpos > 0) { 
        dec %mstartpos 
        inc %mlen 
      } 
      var %calculate = $iif(%mstartpos >= 0,$left(%calculate,%mstartpos)) $+ $chr(40) $+ $mid(%calculate,$calc($iif(%mstartpos == 0,0,%mstartpos +1)),%mlen) $+ $chr(41) $+ $right(%calculate,- $+ %mpos) 
      inc %x 
    } 
  } 
  var %calculate = $replace($remove(%calculate,$chr(44),$chr(61)),x,*,k,*1000,m,*1000000)) 
  return $bytes($calc(%calculate),db) 
}