I've two small questions, I hope you can help me:
First, not really important
I've a code like this
Code: Select all
namespace eval wowa {
variable wchans "test"
variable chars
proc init { args } {
set [namespace current]::chars $::wowa::wchans
}
}
Second question, about arrays (in a namespace)
I'm trying to get a structure of datas like:
chars(me)(0) { "item1" "bla" "item2" "bee" }
chars(me)(1) { "item1" "bla" "item2" "bee" }
chars(him)(0) { "item1" "bla" "item2" "bee" }
chars(him)(1) { "item1" "bla" "item2" "bee" }
So, I've created this small proc:
Code: Select all
foreach line [split $wdata "\n"] {
set char [split $line "|"]
if { [array exists [namespace current]::chars([lindex $char 0])]} {
putlog "Info exists"
set val [array size [namespace current]::chars([lindex $char 0])]
putlog "Setted"
} else {
set val 0
}
putlog "Val is $val"
set [namespace current]::chars([lindex $char 0])($val)(nick) [lindex $char 1]
putlog "Setted: $::wowa::chars([lindex $char 0])($val)(item1)"
set [namespace current]::chars([lindex $char 0])($val)(item2) [lindex $char 2]
putlog "Gives: [array size [namespace current]::chars([lindex $char 0])]"
}
me|test|nothing
me|test1|nothing too
him|bla|test
him|bli|test
This is completely wrong, anyone has an idea ?
Thanks a lot.