Difference between revisions of "Alias"

From Scriptwiki
Jump to: navigation, search
m
m (removing stub-pages, added some identifiers and explanation)
Line 13: Line 13:
 
  }
 
  }
  
 +
== Using Aliases ==
  
 +
=== -l switch ===
 
Using -l switch makes the alias local, so it can only be accessed by aliases/events in the same file, and cannot be used as a command in editbox.
 
Using -l switch makes the alias local, so it can only be accessed by aliases/events in the same file, and cannot be used as a command in editbox.
 
  alias -l testing { return Hello world! }
 
  alias -l testing { return Hello world! }
Line 23: Line 25:
 
  ;if we put the localtest alias into a different file, we'll get the "* /echo: insufficient parameters" again.
 
  ;if we put the localtest alias into a different file, we'll get the "* /echo: insufficient parameters" again.
  
 +
=== $prop ===
 
$prop identifier returns custom properties for your alias ($change_case(hello world).upper -> $prop will return 'upper').
 
$prop identifier returns custom properties for your alias ($change_case(hello world).upper -> $prop will return 'upper').
 
  alias change_case {
 
  alias change_case {
Line 32: Line 35:
 
  ;//echo -a $change_case(HeLLo WorlD!).upper will echo: 'HELLO WORLD!'
 
  ;//echo -a $change_case(HeLLo WorlD!).upper will echo: 'HELLO WORLD!'
  
 +
=== $isid ===
 
$isid identifier will return $true if the alias was called as an identifier
 
$isid identifier will return $true if the alias was called as an identifier
 
  alias testing {
 
  alias testing {
Line 45: Line 49:
 
  ;that would echo "Hello world!", and then give "* /echo: insufficient parameters"
 
  ;that would echo "Hello world!", and then give "* /echo: insufficient parameters"
  
 +
=== $show ===
 
$show returns $true if the alias was NOT called with . to make it silent, and $false if it was
 
$show returns $true if the alias was NOT called with . to make it silent, and $false if it was
 
  alias testing {
 
  alias testing {

Revision as of 09:06, 11 October 2006

<aliasname> [-l] <commands>

mIRC allows you to create aliases and scripts to speed up your IRC session or to perform repetitive functions more easily.

Example:

alias testing {
 echo -a Hello world!
}

And with some identifiers:

alias calculator {
 echo -a $1- = $calc($1-)
}

Using Aliases

-l switch

Using -l switch makes the alias local, so it can only be accessed by aliases/events in the same file, and cannot be used as a command in editbox.

alias -l testing { return Hello world! }
;typing //echo -a $testing in the editbox will result in: * /echo: insufficient parameters 
;let's put this alias into the same file:

alias localtest { echo -a $testing }
;now typing /localtest will echo "Hello world!" into active window
;if we put the localtest alias into a different file, we'll get the "* /echo: insufficient parameters" again.

$prop

$prop identifier returns custom properties for your alias ($change_case(hello world).upper -> $prop will return 'upper').

alias change_case {
 if ($prop == upper) { return $upper($1-) | halt }
 elseif ($prop == lower) { return $lowe($1-) | halt }
 else { return $1- }
}
;//echo -a $change_case(HeLLo WorlD!).lower will echo: 'hello world!'
;//echo -a $change_case(HeLLo WorlD!).upper will echo: 'HELLO WORLD!'

$isid

$isid identifier will return $true if the alias was called as an identifier

alias testing {
  if ($isid) { return Hello world! }
  else { echo -a Hello world! }
}
;both //echo -a $testing and /testing will result in echoing "Hello world!"

;if we did only:
alias testing {
  echo -a Hello world!
}
;that would echo "Hello world!", and then give "* /echo: insufficient parameters"

$show

$show returns $true if the alias was NOT called with . to make it silent, and $false if it was

alias testing {
 if ($show) { 
   msg MyBot auth Myusername $1
 }
 else {
   .msg MyBot auth Myusername $1
 }
}
;/testing PASSWORD -> will show in active: '-> *MyBot* auth Myusername PASSWORD'
;/.testing PASSWORD -> won't show anything, since the msg was also made silent