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.

Difficulty with $nick variable

Old posts that have not been replied to for several years.
Locked
R
Razo
Voice
Posts: 3
Joined: Thu Jan 13, 2005 7:51 pm
Location: Chicago, IL

Difficulty with $nick variable

Post by Razo »

Hello

I have a script that I have been working on for a while now and I cannot get the script to process $nick in a "switch" command. The TCL script does not recognize $nick, which in my thoughts, doesn't seem right.
This script has worked before, I made a few changes to how the arguments were grouped and it still did not work. I have even tried setting the nick to [set nick "[lindex $nick 0]" ]. Would anybody have any suggestions?
I am using Windrop 1.6.17 with TCL library 8.4

Here is the the code :

Code: Select all

bind pub -|- "switch" proc_switch
proc proc_switch {nick host hand chan arg} {
set arguments [lrange $arg 1 end]
set cmd [lindex $arg 0]
set nick [lindex $nick 0]
switch [lindex $cmd 0] {
		"set" { src:set $nick $host $hand $chan $arguments ;putcmdlog ok }
		"control" { src:control $nick $host $hand $chan $arguments ;putcmdlog ok}
		"cinfo" { src:chaninfo $nick $host $hand $chan $arguments}
		"addchan" { src:addchan $nick $host $hand $chan $arguments }
		"delchan" { src:delchan $nick $host $hand $chan $arguments }
		"addowner" { src:addowner $nick $host $hand $chan $arguments }
		"delowner" { src:delowner $nick $host $hand $chan $arguments }
		"addop" { src:addop $nick $host $hand $chan $arguments }
		"cycle" { src:cycle $nick $hand $chan }
		"myinfo" { src:myinfo $nick $hand $chan }
		"die" { src:die $nick $hand $chan $arguments}
		"addcoowner" { src:addcoown $nick $host $hand $chan $arguments }
		"addpeon" { src:addpeon $nick $host $hand $chan $arguments }
		"addvoice" { src:addvoice $nick $host $hand $chan $arguments }
		"clvl" { src:clvl $nick $host $hand $chan $arguments }
		"glvl" { src:glvl $nick $host $hand $chan $arguments}
		"access" { src:access $nick $hand $chan }
		"kick" { src:kick $nick $host $hand $chan $arguments }
		"ban" { src:ban $nick $host $hand $chan $arguments}
		"uba" { src:unbanall $nick $host $hand $chan $arguments }
		"users" { src:users $nick $host $hand $chan $arguments }
		"override" { src:checkride $nick $hand $chan }
		"op" { src:op $nick $host $hand $chan $arguments }
		"deop" { src:deop $nick $host $hand $chan $arguments }
		"voice" { src:voice $nick $host $hand $chan $arguments }
		"v" { src:voice $nick $host $hand $chan $arguments }
		"dv" { src:devoice $nick $host $hand $chan $arguments }
		"devoice" { src:devoice $nick $host $hand $chan $arguments }
		"mode" { src:mode $nick $host $hand $chan $arguments }
		"topic" { src:topic $nick $host $hand $chan $arguments }
		"help" {src:help $nick $hand $chan $arguments}
		"rh" { src:rehash $nick $hand }
		"rs" { src:restart $nick $hand }
		"new" { src:new $nick $hand }
		"addcmd" { src:addcmd $nick $host $hand $chan $cmd $arguments }
		"delcmd" { src:delcmd $chan $cmd } 
		"emote" { src:emote $chan $arguments }
		default { putnotice $nick "Invalid command - [lrange $arg 1 end]" }
		}

}
Thanks for your time.
Razo
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

What's the error message? Also, are you sure the error is happening in this proc and not one of the ones it calls? Try adding "putlog $nick" in a few places to see 1) how far it gets and 2) exactly when the variable "disappears"
R
Razo
Voice
Posts: 3
Joined: Thu Jan 13, 2005 7:51 pm
Location: Chicago, IL

Post by Razo »

I have found out that it stops right at the "switch" statement.
I'm sure that this is not running to the proc that it is calling, the proc that it is calling does not even exist, so I would expect an error message stating that there is no such procedure.

The $nick variable is gone outside, and past the switch command. The error message it returns is :
[19:56] Tcl error [proc_switch]: can't read "nick": no such variable
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Why not make it simpler, make 1-2 line procs for each switch?
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
m
metroid
Owner
Posts: 771
Joined: Wed Jun 16, 2004 2:46 am

Post by metroid »

Code: Select all

bind pub -|- "switch" proc_switch
proc proc_switch {nick host hand chan arg} {
set arguments [lrange $arg 1 end]
set cmd [lindex $arg 0]
switch $cmd {
      "set" { src:set $nick $host $hand $chan $arguments ;putcmdlog ok }
      "control" { src:control $nick $host $hand $chan $arguments ;putcmdlog ok}
      "cinfo" { src:chaninfo $nick $host $hand $chan $arguments}
      "addchan" { src:addchan $nick $host $hand $chan $arguments }
      "delchan" { src:delchan $nick $host $hand $chan $arguments }
      "addowner" { src:addowner $nick $host $hand $chan $arguments }
      "delowner" { src:delowner $nick $host $hand $chan $arguments }
      "addop" { src:addop $nick $host $hand $chan $arguments }
      "cycle" { src:cycle $nick $hand $chan }
      "myinfo" { src:myinfo $nick $hand $chan }
      "die" { src:die $nick $hand $chan $arguments}
      "addcoowner" { src:addcoown $nick $host $hand $chan $arguments }
      "addpeon" { src:addpeon $nick $host $hand $chan $arguments }
      "addvoice" { src:addvoice $nick $host $hand $chan $arguments }
      "clvl" { src:clvl $nick $host $hand $chan $arguments }
      "glvl" { src:glvl $nick $host $hand $chan $arguments}
      "access" { src:access $nick $hand $chan }
      "kick" { src:kick $nick $host $hand $chan $arguments }
      "ban" { src:ban $nick $host $hand $chan $arguments}
      "uba" { src:unbanall $nick $host $hand $chan $arguments }
      "users" { src:users $nick $host $hand $chan $arguments }
      "override" { src:checkride $nick $hand $chan }
      "op" { src:op $nick $host $hand $chan $arguments }
      "deop" { src:deop $nick $host $hand $chan $arguments }
      "voice" { src:voice $nick $host $hand $chan $arguments }
      "v" { src:voice $nick $host $hand $chan $arguments }
      "dv" { src:devoice $nick $host $hand $chan $arguments }
      "devoice" { src:devoice $nick $host $hand $chan $arguments }
      "mode" { src:mode $nick $host $hand $chan $arguments }
      "topic" { src:topic $nick $host $hand $chan $arguments }
      "help" {src:help $nick $hand $chan $arguments}
      "rh" { src:rehash $nick $hand }
      "rs" { src:restart $nick $hand }
      "new" { src:new $nick $hand }
      "addcmd" { src:addcmd $nick $host $hand $chan $cmd $arguments }
      "delcmd" { src:delcmd $chan $cmd }
      "emote" { src:emote $chan $arguments }
      default { putnotice $nick "Invalid command - [lrange $arg 1 end]" }
      }

} 
Try it
User avatar
stdragon
Owner
Posts: 959
Joined: Sun Sep 23, 2001 8:00 pm
Contact:

Post by stdragon »

Hey Razo,

I copied your code into tclsh, and it works fine.. no error about nick.

Also... in case you didn't know, the proc that eggdrop reports the error happening in is not necessarily where the error happens, it is just the bind that triggered the error.

To find out a little bit more, make sure you have the .tcl command enabled, and immediately after the error occurs type

.tcl putlog $errorInfo

Note the capital I in Info, it won't work otherwise. It will hopefully tell you more precisely where the error happened. Paste the exact output here and it should help us find the problem.

ps I tried metroid's code too and it worked fine... no difference
R
Razo
Voice
Posts: 3
Joined: Thu Jan 13, 2005 7:51 pm
Location: Chicago, IL

Post by Razo »

Many thanks,

I found out that whenever I kept rehashing my bot, the procs would not clear themselves out. Therefore, when I checked out .tcl $errorInfo, it kept calling a proc that was not even in pub, just as stdragon said. It came down to having the incorrect arguments in a proc I wrote with the wrong number or arguments, and I had recently had a userfile change, so that contributed to part of the problem.
Thanks again for your time. I appreciate it.

Razo
Locked