mIRC Home    About    Download    Register    News    Help

Print Thread
#143816 02/03/06 11:54 AM
Joined: Mar 2006
Posts: 2
C
Bowl of petunias
OP Offline
Bowl of petunias
C
Joined: Mar 2006
Posts: 2
Hi,

I want that my alias returns a short version of $server.

For example:

I'm on this server: underworld.no.quakenet.org
and I want that my alias ($serv_) returns no.quakenet.org

Another example:

I'm on this server: carouge.ch.eu.undernet.org
and I want that my alias ($serv_) returns eu.undernet.org

I tried it already, but I failed.

Code:
 
alias serv_ {
  if ($status == connected) {                             
    var %numtokserv $numtok($server,46)       
    if (%numtokserv == 3) {                               
      return $server                                      
    }
    elseif (%numtokserv > 3) {                            
      var %inc 0 
      while (3 <= %numtokserv) {                          
        dec %numtokserv                                   
        inc %inc
      }
      return $deltok($server,%inc,46)
    }
    else {
      return bla
    }
  }
}

Joined: Feb 2006
Posts: 54
T
Babel fish
Offline
Babel fish
T
Joined: Feb 2006
Posts: 54
Code:
  
alias serv_ {
  if ($status == connected) {                             
    var %num $numtok($server,46)   
    if (%num == 3) { return $server }
    elseif (%num > 3) { var %i = $calc(%num - 3), %c = $+(1-,%i) | return $deltok($server,%c,46) }
  }
  else { return bla }
}


Joined: Dec 2004
Posts: 66
B
Babel fish
Offline
Babel fish
B
Joined: Dec 2004
Posts: 66
Code:
 
alias serv_ {
  if ($status == connected) {                             
    if ($numtok($server,46) > 3) return $gettok($server, -3-, 46)
    else  return $server
  }
  else { return bla }
}
 

Joined: Feb 2006
Posts: 546
J
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
i assume you wana return $null if $server is also $null? smile this will also preserve server names with 2 period separated tokens (or 1 should that ever exist :P) which $gettok with -3- wont do

Code:
alias serv_ return $deltok(a. $server,-900--4,46)


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
I believe there's a bug in $deltok() here, deleting the first token if the number of tokens in text is outside the specified range (I was trying to figure out why you added that "a. " there).

On a sidenote, wouldn't it be nice if positive-negative ranges worked or $gettok(a b,-3-,32) didn't return $null?

There you go, a bug report and a feature suggestion in a scripts&popups post :tongue:

Last edited by qwerty; 02/03/06 04:01 PM.
Joined: Dec 2002
Posts: 1,541
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Dec 2002
Posts: 1,541
Quote:
There you go, a bug report and a feature suggestion in a scripts&popups post


covering all bases there qwerty?? LOL


Those who fail history are doomed to repeat it

Link Copied to Clipboard