egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Simple, but yet an error!

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
T-Xorcist
Halfop


Joined: 14 Nov 2005
Posts: 47
Location: Netherlands

PostPosted: Mon Nov 14, 2005 6:50 pm    Post subject: Simple, but yet an error! Reply with quote

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
View user's profile Send private message Visit poster's website
T-Xorcist
Halfop


Joined: 14 Nov 2005
Posts: 47
Location: Netherlands

PostPosted: Mon Nov 14, 2005 7:30 pm    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
FTL25
Voice


Joined: 14 Nov 2005
Posts: 17

PostPosted: Tue Nov 15, 2005 12:57 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber