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.

vars with "-" not beening read

Old posts that have not been replied to for several years.
Locked
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

vars with "-" not beening read

Post by Dedan »

It seems that i can not get the egg to read
any var that has a "-" in it.

is this a common syntax error?

Code: Select all

set found-codes 1

bind pubm -|- "*" protect:channel
proc protect:channel {nick uhost handle channel text} {
  global botnick found-codes
  set chan [string tolower $channel]
  if {![botisop $chan] || [isop $nick $chan]} {return 0}
  puthelp "PRIVMSG $chan :code count is $found-codes"
}


[03:58] Tcl error [protect:channel]: can't read "found": no such variable



please help
I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

escape it by enclosing the variable name in {}'s or use set to retrieve the value:

eg: ${botnet-nick} or [set botnet-nick]
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

what are you escaping?
I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Dedan wrote:what are you escaping?
"the name is a sequence of one or more characters that are a letter, digit, underscore, or namespace separators (two or more colons)."
- http://tcl.tk/man/tcl8.4/TclCmd/Tcl.htm#M11
User avatar
Dedan
Master
Posts: 260
Joined: Wed Jul 09, 2003 10:50 pm
Location: Memphis

Post by Dedan »

so, tcl has a problem with vars that have a "-" in them?


what about all those in th conf file?
I once was an intelligent young man, now i am old and i can not remember who i was.
User avatar
user
 
Posts: 1452
Joined: Tue Mar 18, 2003 9:58 pm
Location: Norway

Post by user »

Dedan wrote:so, tcl has a problem with vars that have a "-" in them?
what about all those in th conf file?
Tcl doesn't have a problem with them. Some users have a problem addressing them the right way though :P
You can use any char you like in a variable name, but the $ parser is a bit picky. (like I mentioned in my previous post)

Using "-" in a variable name only leads to extra work when you want variable substitution, so why don't you use "_" instead or start using 'set' to retrieve the value?

I've no idea why the eggdrop developers chose to use "-" :)
Locked