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.

n00b to DCC bindings :x

Old posts that have not been replied to for several years.
Locked
L
LtPhil
Voice
Posts: 26
Joined: Mon Jul 28, 2003 10:25 am

n00b to DCC bindings :x

Post by LtPhil »

i'm using the following code to try and make it so i can send quick e-mail notes while DCC'ed to my bot, but it dies with the error
wrong # args: should be "proc name args body"
while executing
"proc xs_mailnote {hand idx text} {
global botnet-nick
set toaddr [string range $text 0 [expr ([tcl_wordBreakAfter $text 0] - 1)]]
set subject "$..."
this is the code i am (trying to) use:

Code: Select all

bind dcc n mailnote xs_mailnote

proc xs_mailnote {hand idx text} {
  global botnet-nick
  set toaddr [string range $text 0 [expr ([tcl_wordBreakAfter $text 0] - 1)]]
  set subject "${botnet-nick} partyline note from ${hand}"
  set msgbody [string range $text [expr ([tcl_wordBreakAfter $text 0] + 1)] end]
  if {[catch {exec mail -s "${subject}" $toaddr $msgbody}]}
    putlog "Error sending note to $toaddr"
  } {
    putlog "Sent note to $toaddr"
  }
}
:-? [/code]
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

the error explains what's the mistake:
wrong # args: should be "proc name args body"
and your proc is :

Code: Select all

proc xs_mailnote {hand idx text} {
so try to make it proc xs_mailnote {hand idx text bod} { :)
L
LtPhil
Voice
Posts: 26
Joined: Mon Jul 28, 2003 10:25 am

Post by LtPhil »

err okay, that makes sense... but looking at various docs on the web, they kept specifying only three arguments for the proc... so what's the difference between $text and $bod?
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

The "if" is missing a "{", and because of that the rest of your code gets out of sync (in lack of a better word) and the "else" part of the if becomes the 4th argument to "proc"
L
LtPhil
Voice
Posts: 26
Joined: Mon Jul 28, 2003 10:25 am

Post by LtPhil »

wrong # args: should be "proc name args body"
while executing
"proc xs_mailnote {hand idx text body} {
global botnet-nick
set toaddr [string range $text 0 [expr ([tcl_wordBreakAfter $text 0] - 1)]]
set subje..."
-- same error, sir_fz

user: i don't see a problem with the if statement...

Code: Select all

proc xs_mailnote {hand idx text body} {
  global botnet-nick
  set toaddr [string range $text 0 [expr ([tcl_wordBreakAfter $text 0] - 1)]]
  set subject "${botnet-nick} partyline note from ${hand}"
  set msgbody [string range $text [expr ([tcl_wordBreakAfter $text 0] + 1)] end]
#  if {[catch {exec mail -s "${subject}" $toaddr $msgbody}]}
#    putlog "Error sending note to $toaddr"
#  } else {
#    putlog "Sent note to $toaddr"
#  }
  putdcc $idx "${botnet-nick} :: $text :: $body"
}
still produces the error shown above (with or without "body" in the args)

(edit: btw, i put the "else" in there explicitly just to see if it was fussing about that -- no go)
L
LtPhil
Voice
Posts: 26
Joined: Mon Jul 28, 2003 10:25 am

Post by LtPhil »

looking at the error more in-depth, it's acting like it's having a problem with the actual call to proc... but i'm doing

proc name {args} {
body
}


... so i don't get it :-?
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

LtPhil wrote:user: i don't see a problem with the if statement...
Take another look. The code you pasted with the entire if stucture commented out was valid.

Because newlines don't have the same effect between braces this is basically what your code looks like to the parser (count the arguments):

Code: Select all

proc bla {} {if {}} {}
L
LtPhil
Voice
Posts: 26
Joined: Mon Jul 28, 2003 10:25 am

Post by LtPhil »

oof. i see it now. i had to delete and re-write the IF block from scratch... when i did, it worked... then i copied and pasted it into notepad, and copied the original IF statement from my first post, and saw.

/me is enlightened

thank you :D
Locked