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.
Old posts that have not been replied to for several years.
J
Jas0n
Post
by Jas0n » Thu Jul 11, 2002 2:16 pm
I have been setting vars like this...
Code: Select all
set country(south africa) "Code: \002ZA\002 Country: \002South Africa\002"
Then I find out that eggdrop dont like that.
Is there anyway around this with keeping the space?
Thanks
Jason
ppslim
Revered One
Posts: 3914 Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England
Post
by ppslim » Thu Jul 11, 2002 4:47 pm
Jas0n wrote:
Code: Select all
set country(south africa) "Code: \002ZA\002 Country: \002South Africa\002"
Try escaping the space, like you have the control codes. EG
Code: Select all
set country(south\ africa) "Code: \002ZA\002 Country: \002South Africa\002"
Another method method includes
Code: Select all
set temp "south africa"
set country($temp) "Code: \002ZA\002 Country: \002South Africa\002"
J
Jas0n
Post
by Jas0n » Thu Jul 11, 2002 5:53 pm
I tried what you said an adding the '\' dont work, because it accepts it has 'south\ africa' not just 'south africa'
Anymore ideas?
Petersen
Owner
Posts: 685 Joined: Thu Sep 27, 2001 8:00 pm
Location: Blackpool, UK
Post
by Petersen » Thu Jul 11, 2002 6:46 pm
spaces in variables == bad. a space is a core delimiter - using them in varible names will lead to problems later on. this is a core programming rule, which has been in effect ever since the concept of a named variable (or constant) was born. substitute your spaces for underscores (_)
J
Jas0n
Post
by Jas0n » Thu Jul 11, 2002 7:11 pm
hmmmz.
Well this is wot im trying to do...
Code: Select all
if {$misc1 == "country"} {
set chr [string tolower $misc2]
if {![info exists country($chr)]} {
putserv "NOTICE $nick :Error: \002Country does not exist\002"
return 0
}
putserv "PRIVMSG $chan :$country($chr)"
}
Example of how the vars are set...
Code: Select all
set country(south africa) "Code: \002ZA\002 Country: \002South Africa\002"
Code: Select all
set country(za) "Country: \002South Africa\002 Code: \002ZA\002"
So any ideas how i can do it using the underscores then?
ppslim
Revered One
Posts: 3914 Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England
Post
by ppslim » Fri Jul 12, 2002 5:24 am
the setting should be
Code: Select all
set country(south_africa) "Code: \002ZA\002 Country: \002South Africa\002"
In your script, as well as performing a [string] tolower command, your should run it through a de-spacer if you like.
Code: Select all
proc de_spacer {str} {
regsub -all -- $str { } {_} str
return $str
}
Once this is in the script, you can pass the country names through it, to convert them to array identifiers.
J
Jas0n
Post
by Jas0n » Fri Jul 12, 2002 9:15 am
ok then so it should be.....
Code: Select all
if {$misc1 == "country"} {
set chr [string tolower $misc2]
set checkcountry [de_spacer $chr]
if {![info exists country($checkcountry)]} {
putserv "NOTICE $nick :Error: \002Country does not exist\002"
return 0
}
putserv "PRIVMSG $chan :$country($checkcountry)"
}
Code: Select all
proc de_spacer {str} {
regsub -all -- $str { } {_} str
return $str
}
Think thats right, but it dont work, keeps saying country does not exist...
ppslim
Revered One
Posts: 3914 Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England
Post
by ppslim » Fri Jul 12, 2002 10:27 am
I have got the syntax of the regsub command mixed up.
It should actualy be
regsub ?switches? exp string subSpec varName
I got the exp and string the wrong way round
it should be
Code: Select all
proc de_spacer {str} {
regsub -all -- { } $str {_} str
return $str
}
J
Jas0n
Post
by Jas0n » Fri Jul 12, 2002 11:25 am
ok then fixed it but now getting...
[16:17] Tcl error [pub:Cmds]: can't read "country(south)": no such element in array
Sorry to be such a pain!!!!!
ppslim
Revered One
Posts: 3914 Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England
Post
by ppslim » Fri Jul 12, 2002 11:53 am
Then the variable being passed only has the word south in it.
Seeing the rest of the script would help
J
Jas0n
Post
by Jas0n » Fri Jul 12, 2002 12:18 pm
Code: Select all
proc pub:Cmds {nick uhost handle chan text} {
set misc1 "[lindex $text 0]"
set misc2 "[lindex $text 1]"
if {$misc1 == "country"} {
set chr [string tolower $misc2]
regsub -all -- { } $chr {_} chr
if {![info exists $country($chr)]} {
putserv "NOTICE $nick :Error: \002Country does not exist\002"
return 0
}
putserv "PRIVMSG $chan :$country($chr)"
}
}
ppslim
Revered One
Posts: 3914 Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England
Post
by ppslim » Fri Jul 12, 2002 1:56 pm
Code: Select all
proc pub:Cmds {nick uhost handle chan text} {
set misc1 [lindex [split $text] 0]
set misc2 [lrange [split $text] 1 end]
if {$misc1 == "country"} {
set chr [string tolower $misc2]
regsub -all -- { } $chr {_} chr
if {![info exists $country($chr)]} {
putserv "NOTICE $nick :Error: \002Country does not exist\002"
return 0
}
putserv "PRIVMSG $chan :$country($chr)"
}
}