Just adding a few comments :[/b])
Code:
alias works {
 
  ; set a starting point to loop through connections
  var %i = 1

  ; loop until there are no more connections
  while $scon(%i) {
 
    ; switch the connection
    scon %i
 
    ; perform a few commands
    echo -s Connection: %i
    echo -s Cid: $cid
    echo -s Server: $iif($server,$server,$status)
 
    ; inc %i and continue on with the looping
    inc %i
  }
}