mIRC Homepage
Posted By: niceguy4 functions? - 04/05/04 04:17 AM
i'm looking how to create functions. C++ has function. I have some code that i need to be called in my script a couple of times but i dont want to just make copys of the code. If someone could point me to some help or tell me the syntax that would be great.
Posted By: andymps Re: functions? - 04/05/04 05:21 AM
if im write.. u r talking about aliases..... example:
alias Hi {
  echo -a HI $me

if thats not what u mean explain further and im sure i can help
Posted By: Hammer Re: functions? - 04/05/04 08:08 AM
alias MyFunction return 3
Posted By: starbucks_mafia Re: functions? - 04/05/04 11:46 AM
Just to expand on the other two answers:

In mIRC scripting, procedures and functions are more commonly referred to as commands and identifiers respectively. Both also come under the term 'alias', and it's the alias statement that is used to define them. When defining an alias you don't specify the arguments as you would in a language like C++, instead each argument is stored in the special identifier set $n, where n is a number. So the first argument is $1, the second $2, and so on.

Here's a simple identifier example to be used in Remotes (Alt+R);
alias add {
return $calc($1 + $2 + $3)

You could then use /echo -a $add(1, 2, 3) to echo 6 to the active window.

Here's a simple command example that does the same thing but echoes the result internally instead of returning it:
alias add {
echo -a $calc($1 + $2 + $3)

You could then use /add 1 2 3 to echo 6 to the active window.

Check the Aliases section of mIRC's help file for more info (/help aliases).

Note: mIRC can also load alias files, which can contain only alias definitions (you can see/edit alias files from the Aliases tab in the mIRC Script Editor). With alias files you don't need to use the alias keyword to define an alias, since it's implied by the fact that it's in an alias file.
© mIRC Discussion Forums