Advertisement
imk0tter

Untitled

May 7th, 2021
2,111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.62 KB | None | 0 0
  1. alias calctok {
  2.   hinc -m CALCTOKEN COUNT
  3.   var %htable CALCTOKEN $+ $hget(CALCTOKEN,COUNT)
  4.   hadd -m %htable COUNT 0
  5.  
  6.   var %tokens $1-
  7.  
  8.   var %numberOfTokens $pos(%tokens,$chr(40),0)
  9.   var %currentCalculation
  10.  
  11.   while %numberOfTokens {
  12.     var %numberOfOpeners $pos(%tokens,$chr(40),0)
  13.  
  14.     var %currentOpenerOffset $pos(%tokens, $chr(40), %numberOfOpeners)
  15.     var %currentCloserOffset $calc(%currentOpenerOffset + $pos($mid(%tokens,%currentOpenerOffset $+ -),$chr(41),1))
  16.     var %length $calc(%currentCloserOffset - %currentOpenerOffset)
  17.  
  18.     var %currentCalculation $mid($mid(%tokens,$calc(%currentOpenerOffset),%length),2,-1)
  19.  
  20.     var %tokens $mid(%tokens,1,$calc(%currentOpenerOffset - 1))  $mid(%tokens, %currentCloserOffset $+ -)
  21.     if ( !isin %currentCalculation) spush %htable %currentCalculation
  22.     else {
  23.       var %z $pos(%currentCalculation,,0)
  24.  
  25.       while %z {
  26.         var %currTok $spop(%htable)
  27.         var %currentCalculation $replacetok(%currentCalculation,,-1,$calc(%currTok))
  28.         if ( !isin %currentCalculation) spush %htable %currentCalculation        
  29.         dec %z  
  30.       }
  31.     }
  32.     dec %numberOfTokens
  33.   }
  34.   hfree %htable
  35.   return $calc(%currentCalculation)
  36. }
  37.  
  38. alias replacetok {
  39.   var %pos $pos($1,$2,$iif($3 > 0,$3,$calc($pos($1,$2,0) + $3 + 1)))
  40.   return $+($left($1,$calc(%pos - 1)),$$4,$right($1,- $+ $calc(%pos + $len($2) - 1)))
  41. }
  42.  
  43. alias -l spush {
  44.   var %htable $1
  45.   hinc -m %htable COUNT
  46.   hadd -m %htable $hget(%htable,COUNT) $2-
  47. }
  48.  
  49. alias -l spop {
  50.   var %htable $1, %count $hget(%htable,COUNT)
  51.   hdec -m %htable COUNT
  52.   return $hget(%htable,%count)
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement