This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

error: wrong # args:

Old posts that have not been replied to for several years.
Locked
t
tqo

error: wrong # args:

Post by tqo »

hello,

I am getting a weird error when I try to start my eggdrop.
I have two similar procs one to handle public commands and one to handle msg commands. Both result in the same error. When I move one proc above the other in my code, the error seems to stay on the same line (perhaps there's something wrong with both my procs?).


[00:57] Tcl error in file 'eggdrop.conf':
[00:57] wrong # args: should be "proc name args body"
while executing
"proc do_commandsm {which nick uhost hand args} "
(file "scripts/tqobot/commands.tcl" line 1)
invoked from within
"source scripts/tqobot/commands.tcl"
(file "scripts/tqobot.tcl" line 21)
invoked from within
"source scripts/tqobot.tcl"
(file "eggdrop.conf" line 1334)
[00:57] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)


here is the beginning 10 lines of the proc commandsm:

Code: Select all

proc do_commandsm {which nick uhost hand args} {
global botnick att Nickserv Chanserv
regsub -all {\{} $args "" args
regsub -all {\}} $args "" args
regsub -all {\"} $args "" args
regsub -all {\'} $args "" args
set att_cmd [lindex $args 0]
set att_string [lrange $args 1 end]
set att_string2 [lrange $args 2 end]
set att_arg1 [lindex $args 1]
set att_arg2 [lindex $args 2]
set att_arg3 [lindex $args 3]
... more stuff ...
}
the syntax seems fine. I'm not quite sure what I am doing wrong :(
Anyone ever had this error before? Any way to fix this?

Thanks!
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Well for a start, you have complicated things for yourself in this script.

You are using lots of usless regsubs, that can be removed.

The reason you have to use regsub's, is because of your use of the $args variable.

The $args variable has a special usage.

Here is the Tcl man page with the relevant info
If the last formal argument has the name args, then a call to the procedure may contain more actual arguments than the procedure has formals. In this case, all of the actual arguments starting at the one that would be assigned to args are combined into a list (as if the list command had been used); this combined value is assigned to the local variable args.
To add injury to insult, you then proced to use list commands (lindex, lrange) on a non-valid list.

The quickest method of visit this, would to replace your example code with the following.

Code: Select all

proc do_commandsm {which nick uhost hand arg} { 
global botnick att Nickserv Chanserv 
set args [split $arg]
set att_cmd [lindex $args 0] 
set att_string [lrange $args 1 end] 
set att_string2 [lrange $args 2 end] 
set att_arg1 [lindex $args 1] 
set att_arg2 [lindex $args 2] 
set att_arg3 [lindex $args 3] 
... more stuff ... 
}
This will remove the need for the regsubs, and allow proper use (and remove any nasty bugs that will popup later) of the list commands.

On top of this, what editor are you using?
t
tqo

Post by tqo »

hello,

Sorry, I have only started playing around with tcl in the past few days. Anyway I understand what you are saying with the list. Basically I copied code from tekkbot (not sure who the author is, but gave credit where needed) and implemented it into something I wrote.

I tried the replacement code you posted and still got the same error. Perhaps the proc that calls do_commandm is at fault. I have decided to try to rewrite most of the code to my own, which will hopefully let me learn exactly how everything works. Do you have any suggestions as to how I could organize my args in a better fashion?

Thanks
t
tqo

Post by tqo »

oh one more thing I forgot to answer,

I was using wordpad in windows to edit my tcl files over my samba network, but I suppose that it isnt the best thing to use. I am now using EditPlus which seems like it will work well
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

There is no real need to organise vars.

So long as you give them meaningful names, and stay away from the name args, your should be fine.

As for the route problem, it may well be due to samba and wordpad.

I would sugest FTP or SCP (available with putty) for uploading.
Locked