First, /msg is a builtin command, if you create a custom alias available globally (no -l switch used), people who call /msg will call your alias instead of the built-in, so that's very bad practice, especially if you are new.

Now, let's assume you named the alias 'my_msg'.

Calling $my_msg() is not required and not useful, and can even be problematic.
When you call an alias as an $identifier, most of the time it's because you want to return a value from it, if you already know you will never have to return a value from it, you don't need to call the alias as an identifier, calling it as a command is prefered.
Regardless, it works for you here because you're not returning a value from 'my_msg', if you were to return a value like '5', that value would be interpreted as the command, and /5 would be executed, which is not something you want.

They are various way to pass the information to the alias according to which event occurs.
-if called as an identifier and assuming you're not already using properties, you can use them to pass the information:

$my_msg($1,message).called_from_alias
$my_msg($chan,message).called_from_event

inside the alias, $prop would refer to 'called_from_alias' and/or 'called_from_event'.

-you can pass the information as a parameter to the identifier/command

But in this typical situation, it's not to the /my_msg alias to figure out things, it's up to the routine calling it to pass the correct information, the location and the message:

Code:
alias my_msg {
msg $1 $2-
}

alias aliasName {
 my_msg $1 Alias Message
}
on *:TEXT:!command*:#:{
 my_msg $chan Command Message
}


Now, sometimes you need to know from which routine you called the alias (just not needed here) and in this case you pass a parameter:

Code:
alias my_msg {
if ($1 == alias) msg $2 Alias: $3-
elseif ($1 == event) msg $2 event: $3-
elseif ($1 == whatever) ...
}

alias aliasName {
 my_msg alias $1 Alias Message
}
on *:TEXT:!command*:#:{
 my_msg event $chan Command Message
}


#mircscripting @ irc.swiftirc.net == the best mIRC help channel