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.

Cannot assign proc return value to a variable

Help for those learning Tcl or writing their own scripts.
Post Reply
User avatar
z_one
Master
Posts: 269
Joined: Mon Jan 14, 2002 8:00 pm
Location: Canada

Cannot assign proc return value to a variable

Post by z_one »

Ok I'm writing a script with many functions but, assuming all variables in the code below are declared and the proc notice:nochannotice calls none:bankickthenick, why do I get the following error when a nick called tester (for example) sends a channel notice:

Tcl error: invalid command name "tester!*@*""

Code: Select all

bind notc - "*" notice:nochannotice

proc none:banmask {p_chan p_nick p_bantype} {
  set l_uhost [getchanhost $p_nick $p_chan]
  switch -- $p_bantype {
    1 { set l_banmask "$p_nick!*@*"}
    2 { set l_banmask "*!*@[lindex [split $l_uhost @] 1]" }
    3 { set l_banmask "*!*$l_uhost" }
    default { set l_banmask "*!*@[lindex [split $l_uhost @] 1]" }
  }
  if {[$l_banmask" == "*!*@*"]} {
    return 0
  } else {
    return $l_banmask
  }
}


proc none:bankickthenick {p_nick p_chan} { 
  if {[botisop $p_chan] && [onchan $p_nick $p_chan]} {
    set l_banmask [none:banmask $l_chan $l_nick 1]
    putserv "mode $l_chan +b $l_banmask"
    putserv "kick $l_chan $p_nick"
  }
} 
isn't the following line

Code: Select all

set l_banmask [none:banmask $l_chan $l_nick 1]
the correct way to do this if I want to assign the return value none:banmask to the variable l_banmask ?
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

Did you bother reading the FAQ and the Sticky about how to get proper DEBUG data?

You didn't tell us the full error, and I don't feel like sitting here figuring out your script's logic, so please post the output of .set errorInfo (after reading the FAQ section dealing with finding bugs/script errors, and reading the Sticky about how to help us help you.)

And if you come back and say "all .set errorInfo says is "What? You Need Help?"" we're going to collectively neuter you :)
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Re: Cannot assign proc return value to a variable

Post by user »

z_one wrote:Tcl error: invalid command name "tester!*@*""
...

Code: Select all

if {[$l_banmask" == "*!*@*"]} {...}
Why did you put brackets around that expression?
Have you ever read "The Manual"?
User avatar
z_one
Master
Posts: 269
Joined: Mon Jan 14, 2002 8:00 pm
Location: Canada

Post by z_one »

User, because it was saying "invalid command name" so I though it was trying to evaluate the user's ban mask as a command.

rosc2112, thanks. I'll check the threads you indicated.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

z_one wrote:User, because it was saying "invalid command name" so I though it was trying to evaluate the user's ban mask as a command.
That's exactly what it is doing and it is BECAUSE OF THE BRACKETS (not braces), so get rid of them :P
This is extremely basic stuff... read http://tcl.tk/man/tcl8.4/TclCmd/Tcl.htm#M10
Have you ever read "The Manual"?
User avatar
z_one
Master
Posts: 269
Joined: Mon Jan 14, 2002 8:00 pm
Location: Canada

Post by z_one »

Damn ! :oops:
Lol it's been years since I last wrote TCL code. I guess I need to re-read that stuff and refresh my memory !
Thanks guys.
Post Reply