mIRC Home    About    Download    Register    News    Help

Print Thread
functions? #81804 04/05/04 04:17 AM
Joined: May 2004
Posts: 1
N
niceguy4 Offline OP
Mostly harmless
OP Offline
Mostly harmless
N
Joined: May 2004
Posts: 1
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.

Re: functions? #81805 04/05/04 05:21 AM
Joined: Apr 2003
Posts: 300
A
andymps Offline
Fjord artisan
Offline
Fjord artisan
A
Joined: Apr 2003
Posts: 300
if im write.. u r talking about aliases..... example:
Code:
alias Hi {
  echo -a HI $me
}

if thats not what u mean explain further and im sure i can help


Liek OMG Yuo Stoleded my MageHurtzzzz!!!11
Re: functions? #81806 04/05/04 08:08 AM
Joined: Dec 2002
Posts: 1,321
H
Hammer Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Dec 2002
Posts: 1,321
alias MyFunction return 3


DALnet: #HelpDesk and #m[color:#FF0000]IR[color:#EEEE00]C
Re: functions? #81807 04/05/04 11:46 AM
Joined: Dec 2002
Posts: 2,962
S
starbucks_mafia Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 2,962
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.


Spelling mistakes, grammatical errors, and stupid comments are intentional.