adding new alias check

By ch1zra on Jul 19, 2005

when you use /alias command, if the alias with name given exists, it automaticaly gets replaced. when you use this code, the script checks is there an alias with given name, and if there is, you get asked do you want to replace an old alias with new one.

Just to be sure... :]

alias alias {
  ; first we check is there an alias with same name
  if ($isalias($1)) {
    ; if htere is an alias with same name, script asks you do yo want to replace it with new one
    if ($input(There is already an alias called $1 in $nopath($isalias($1).fname) with function  : $crlf $& 
      $crlf $isalias($1).alias $crlf $crlf Do you want to override it and set it to : $crlf $crlf $2- $& 
      $crlf $crlf ?,yw,Alias $1 already exists!) == $true) {
      ; then we add the new alias
      alias $1-
      echo -a [Alias] Alias " $+ $color(info) $+ $1 $+ " reasigned to new function " $+ $color(info) $+ $2- $+ "
  else {
    ; If there is no alias with such name, then it's simply added.
    alias $1-
    echo -a [Alias] New alias " $+ $color(info) $+ $1 $+ " added with function " $+ $color(info) $+ $2- $+ "


Sign in to comment.
ch1zra   -  Oct 25, 2011

no problems mate, glad my work helped someone :)
back in the day when I wrote it, it was meant for developers mainly :)

extio   -  Oct 25, 2011

extremely useful for another reason, i needed to know how to check for aliasis. for a game script im working on... thanks much for using $isaliase so i could see how to use it.

ch1zra   -  Jul 21, 2005

well, yes.. but it can also be used in scripts, to warn users if they try to replace any of aliases.

supergeo   -  Jul 20, 2005

Not very practical, but very impressive coding. This is more of a script for developers I think.

ch1zra   -  Jul 19, 2005

well, it prevents accidental replacing of aliases.

also, if alias is somewhere in rfiles, and it has structure eg:
alias somealias {
.blah line 1
blah line 2

the function will be returned like :
\" alias somealias { \"
it displays aliases nice only if they\'re singleline.
will look into that. besides the output possible problem, the snippet works like a charm :)

henrikthesexy   -  Jul 19, 2005

what is the point with this snippets???

Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.