Advertisement
Iire

$ieif ($iif with elseif)

Aug 11th, 2011
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
mIRC 0.57 KB | None | 0 0
  1. ; Untested
  2. ; Returns the value (V) following the FIRST true conditional (C).
  3. ; If no conditionals are true, returns final parameter (E) if $0 is odd, else $null
  4. ; Syntax: $ieif(C1,V1[,C2,V2,C3,...][,E])
  5. /*
  6. Examples: {
  7.  
  8.   $ieif(3 == 1,x,3 == 2,y,3 == 3,z) = z
  9.  
  10.   $ieif(3 == 3,x,2 == 2,y) = x
  11.  
  12.   $ieif(3 == 1,x,3 == 2,y,z) = z
  13.  
  14.   $ieif(3 == 1,x,3 == 2,y) = $null
  15.  
  16. }
  17. */
  18. alias ieif {
  19.   var %c 1, %v 2
  20.   while (%v <= $0) {
  21.     if ( [ $ [ $+ %c ] ] ) return [ $ [ $+ %v ] ]
  22.     inc %c 2
  23.     inc %v 2
  24.   }
  25.   elseif ($0 \\ 2) return [ $ [ $+ $0 ] ]
  26.   else return
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement