Advertisement
imk0tter

Untitled

May 9th, 2021
1,877
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 1.34 KB | None | 0 0
  1. alias parserange {
  2.   var %input $1
  3.   var %maxRange $2
  4.  
  5.   var %startNumber
  6.   var %endNumber
  7.  
  8.   ;if the first character is a -, the first parameter is a negative number; proceed to second - or end of the string
  9.   var %flag $iif($left(%input,1) == -,$true,$fale)
  10.  
  11.   var %a $pos(%input,-,1)
  12.   var %b $token(%input,1,45)
  13.  
  14.   if %a == $len(%input) {
  15.     ;second - as at end of string (range encountered)
  16.     %startNumber = $iif(%flag,$calc(%maxRange - %b + 1),%b )
  17.     %endNumber = %maxRange
  18.   }
  19.   else if !%a {
  20.     ;no - after the first token; no range
  21.     %startNumber = $token(%input,1,45)
  22.     %endNumber = %startNumber
  23.   }
  24.   else {
  25.     ;range encountered; second number
  26.     var %startNumber  $iif(%flag,$calc(%maxRange - %b + 1),%b)
  27.  
  28.     var %input $iif(%flag,$right(%input,-1),%input)
  29.  
  30.     ;proceed to first - or end of string, and if there is a positive or negative integer
  31.  
  32.     var %a $iif($Pos(%input,-,1),$v1,0)
  33.     var %b $iif($pos(%input,-,2),$v1,0)
  34.  
  35.     if %b > 0 && $calc(%b - %a) == 1 {
  36.       ;second integer is negative,
  37.       var %endNumber $calc(%maxRange - $token(%input,2,45) + 1)
  38.     }
  39.     else if %b == 0 {
  40.       ;second integer is positive
  41.       var %endnumber $token(%input,2,45)
  42.     }
  43.     else {
  44.       + unknown condition
  45.       var %endnumber $token(%input,2,45)
  46.     }
  47.   }
  48.   return %startNumber %endNumber
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement