| View previous topic :: View next topic |
| Author |
Message |
T-Xorcist Halfop
Joined: 14 Nov 2005 Posts: 47 Location: Netherlands
|
Posted: Mon Nov 14, 2005 6:50 pm Post subject: Simple, but yet an error! |
|
|
When I enter the following code:
| Code: | bind msg n kick trap_msg
proc trap_msg {nick uhost hand text} {
set whom [lindex $text 0]
set where [lindex $text 1]
if {[onchan $whom $where]} {
putquick "KICK $where $whom :Requested"
} else {
putquick "NOTICE $nick: \002$whom\002 zit niet in \002$where\002"
}
}
|
it will give this error in my log file:
| Code: | | Tcl error [trap_msg]: wrong # args: should be "trap_msg nick uhost hand text" |
What am I doing wrong and could someone give me more information howto know what and when you need sertain args?
Thanks! _________________ is-1337.org IRC server! |
|
| Back to top |
|
 |
T-Xorcist Halfop
Joined: 14 Nov 2005 Posts: 47 Location: Netherlands
|
Posted: Mon Nov 14, 2005 7:30 pm Post subject: |
|
|
| Code: | bind msg n kick trap_msg
proc trap_msg {nick uhost hand text args} {
set where [lindex $text 0]
set whom [lindex $text 1]
if {[onchan $whom $where]} {
putquick "KICK $where $whom :Requested"
} else {
putquick "NOTICE $nick: \002$whom\002 zit niet in \002$where\002"
}
} |
Well this works, but can anyone explain we how to use the args and when?
Example above: {nick uhost hand text args} _________________ is-1337.org IRC server! |
|
| Back to top |
|
 |
FTL25 Voice
Joined: 14 Nov 2005 Posts: 17
|
Posted: Tue Nov 15, 2005 12:57 am Post subject: |
|
|
From _SunMar_ 's tut @ SUNiNET:
| Quote: | The syntax of the proc command is proc <name> { <parameters> } { <body> }.
The <parameters> are the variables the procedure must put its received parameters in.
You need to specify a variable for each parameter here that will be sent to the procedure. All the variables you give have to be seperated by spaces.
...
There is one exception to this rule though. If you call the last variable of <parameters> "args" than you may call upon the procedure with more parameters than you have defined in <parameters>.
In this case all of the parameters you give to the procedure up from the point where the argument "args" start is put in $args. They are put into $args as if the list command was used to make $args. |
Maybe that will help... |
|
| Back to top |
|
 |
|