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.

wrong # args in proc definition

Old posts that have not been replied to for several years.
Locked
S
Solarin
Voice
Posts: 29
Joined: Wed Apr 09, 2003 1:50 pm
Location: Sydney Australia
Contact:

wrong # args in proc definition

Post by Solarin »

I am confused as to why I would receive the following error:

wrong # args: should be "proc name args body" while executing "proc rwb_cmode {nick uhost hand chan mc {victim ""}} { ..."

The bind statment is as follows:
bind mode - * rwb_cmode

Any help would be greatly appreciated. I have also tried the following:

Code: Select all

proc rwb_cmode_fix {nick uhost hand chan mc {victim ""}} {
  if {$victim != ""} {
    append mc "$victim"
  }
  rwb_cmode $nick $uhost $hand $chan $mc
}

proc rwb_cmode {nick uhost handle channel args} {
  set nick [string tolower $nick]
  set change [string tolower [lindex [split $args] 0]]
  set victim [join [lrange [split $args] 1 end]]...
It would then get upset about the proc rwb_cmode line. *shrugs*
W
Weirdo
Master
Posts: 265
Joined: Sat Apr 27, 2002 8:00 pm
Location: Manchester, England

Post by Weirdo »

what kind of binds? pub/pubm? msg?

That error usually occurs when you have either too many, or not enough variables in the { } after the proc <procname> bit.

Might be worth making ms or victim global, and out of the brackets.
User avatar
Papillon
Owner
Posts: 724
Joined: Fri Feb 15, 2002 8:00 pm
Location: *.no

Post by Papillon »

change
bind mode - * rwb_cmode
to
bind mode - * rwb_cmode_fix

restart the bot and try again
Elen sila lúmenn' omentielvo
e
egghead
Master
Posts: 481
Joined: Mon Oct 29, 2001 8:00 pm
Contact:

Re: wrong # args in proc definition

Post by egghead »

Solarin wrote:I am confused as to why I would receive the following error:

wrong # args: should be "proc name args body" while executing "proc rwb_cmode {nick uhost hand chan mc {victim ""}} { ..."


It would then get upset about the proc rwb_cmode line. *shrugs*
Looking at the error message and the code it seems your binds are not updated, probably due to your debugging efforts. The error message refers to "proc rwb_cmode " where the list of arguments are those of "proc rwb_cmode_fix".

There are 2 other issues on the code you have shown:

1. "append mc "$victim" . This will make a new string which does not contain a space. It will look something like: "+ovictim". This single string is then given as the last argument ($mc) when you call rwb_cmode in "rwb_cmode $nick $uhost $hand $chan $mc"

2. in the rwb_cmode proc you use the split argument on $args. Note however that "args" has a special meaning in Tcl.

If you want to run the script on a recent bot (1.6.13), there is no need to use the 2 procs. tcl-commands.doc will give the exact amount of variables you must declare for a bind to MODE.
S
Solarin
Voice
Posts: 29
Joined: Wed Apr 09, 2003 1:50 pm
Location: Sydney Australia
Contact:

Post by Solarin »

Ok I appeared to have confused some people by showing a previous version of the code and part of the current. I am throwing the current version down below in hopes to dispel confusion and find a solution:

Code: Select all

bind mode - * rwb_cmode

#### Start_modeprocs

proc rwb_cmode {nick uhost hand chan mc {victim ""}} {
  set nick [string tolower $nick]
  
  if {$mc == "+b"} {
    foreach address [$wildbans] {
      if {[[string tolower $victim] == [string tolower $address]]} {
        if {$nick == "chanop"} {
          PRIVMSG ChanOP :unban $chan $victim 
          continue
        } else {
          pushmode $chan -b $victim
          continue
        } 
      } #endif
    } #endforeach
  } #endif
  return 0
} #endproc rwb_cmode
That produces the following error:
wrong # args: should be "proc name args body" while executing "proc rwb_cmode {nick uhost hand chan mc {victim ""}} { ..."
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Code: Select all

} #endif 
  return 0 
} #endproc rwb_cmode
It is trating the comment as part of the command.

COmment must only be at the start of a command line.

To end a command line, either use return to drop 1 line, or use the ; character

Thus making the code

Code: Select all

}; #endif 
  return 0 
}; #endproc rwb_cmode
Note it applies to the likes of the if command to (infact any line).
S
Solarin
Voice
Posts: 29
Joined: Wed Apr 09, 2003 1:50 pm
Location: Sydney Australia
Contact:

Post by Solarin »

Ahhh thanks for your help ppslim. That all worked fine. :)

Another question I'm having regarding the same script:

I'm receiving the following error:
[13:52] Tcl error [rwb_cmode]: invalid command name "*!*@* @* !*@* @ *!*@vw-23402.somehost.net"

Please refer to my previous post with code snippet and add the following before the bind statement:
set wildbans "*!*@* @* !*@* @ *!*@vw-23402.somehost.net"

and add:
global wildbans
before the set nick statement.

Why is that error resulting at runtime at foreach address [$wildbans] {?
User avatar
caesar
Mint Rubber
Posts: 3776
Joined: Sun Oct 14, 2001 8:00 pm
Location: Mint Factory

Post by caesar »

May I ask why you don't use an check if matches eggdrop's mask? something like [string match "$ban" "$botname"]
Once the game is over, the king and the pawn go back in the same box.
S
Solarin
Voice
Posts: 29
Joined: Wed Apr 09, 2003 1:50 pm
Location: Sydney Australia
Contact:

Post by Solarin »

Yeah
string match <string> <string>
would be better to use here; however, that still will not solve my problem.
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Code: Select all

foreach address [$wildbans] {
Anything with the square ([]) brackets is evaluated as a Tcl command, and in its place, the return value is used.

As such, in the above, you are telling it to evaluate the contents ot he variable $wildbans as a command.

Dropping the [] should work.
Locked