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.

Arrays

Old posts that have not been replied to for several years.
Locked
J
Jas321

Arrays

Post by Jas321 »

I searched the forum, but couldnt find an specific answer for my problem. This use to work, but doesnt seem to work anymore.

In the script I would do:
proc myproc {} {
global botnick settings
foreach c [channels] {
set settings($c) "0"
}
}

However, now it just comes back with:
can't read "settings(#mychan)": no such variable

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

Post by stdragon »

Are your names in the proper case? You should use [string tolower $c] in the array to be sure. Also why not do ".tcl array names settings" and see what's in there.
User avatar
z_one
Master
Posts: 269
Joined: Mon Jan 14, 2002 8:00 pm
Location: Canada

Post by z_one »

At the risk of repeating what stdragon said, since he said it first :)
I agree with him 100% because I had the same problem, and this is how I solved it.

Code: Select all

proc myproc {} { 
global botnick settings 
foreach c [channels] { 
set settings([string tolower $c]) "0" 
} 
}
and in the other procedure where you use settings($chan)
put this line immediately after the global declaration (if any)

Code: Select all

set chan [string tolower $chan]
So now both your array references match since they are forced to lower case.
r
rolandguy
Voice
Posts: 25
Joined: Wed Aug 13, 2003 1:50 pm

Post by rolandguy »

are you sure that the error is coming from that proc? shouldnt get that error unless reading the var :/

roland
Locked