<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-gb">
	<link rel="self" type="application/atom+xml" href="https://forum.eggheads.org/app.php/feed/topic/18136" />

	<title>egghelp/eggheads community</title>
	<subtitle>Discussion of eggdrop bots, shell accounts and tcl scripts.</subtitle>
	<link href="https://forum.eggheads.org/index.php" />
	<updated>2010-11-16T17:52:26-04:00</updated>

	<author><name><![CDATA[egghelp/eggheads community]]></name></author>
	<id>https://forum.eggheads.org/app.php/feed/topic/18136</id>

		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2010-11-16T17:52:26-04:00</updated>

		<published>2010-11-16T17:52:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95110#p95110</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95110#p95110"/>
		<title type="html"><![CDATA[Two questions: namespaces and arrays]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95110#p95110"><![CDATA[
Thanks a lot nml375.<br><br>Concerning my "array trouble", have you any alternative idea to solve my trouble ? Using dict seems peharps the solution ?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Tue Nov 16, 2010 5:52 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2010-11-16T15:16:35-04:00</updated>

		<published>2010-11-16T15:16:35-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95104#p95104</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95104#p95104"/>
		<title type="html"><![CDATA[Two questions: namespaces and arrays]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95104#p95104"><![CDATA[
First part:<br>I'd just use the <strong class="text-strong">variable</strong> command in a similar manner to the <strong class="text-strong">global</strong> command:<div class="codebox"><p>Code: </p><pre><code>namespace eval wowa {  variable wchans "test"  variable chars  proc init { args } {    variable wchans    variable chars    set chars $wchans  }}</code></pre></div>As for the second part, I'm having a hard time following what you intend to achieve, and what the actual/expected results are. However, I do notice that you try to use multi-dimensional arrays. This is not supported by tcl, which will flatten the array index to whatever is between the outer (). Thus, <strong class="text-strong">array size ::wowa::chars([lindex $char 0])</strong> will not produce the result you expect, but most likely always 0.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Nov 16, 2010 3:16 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2010-11-16T08:04:34-04:00</updated>

		<published>2010-11-16T08:04:34-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=95095#p95095</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=95095#p95095"/>
		<title type="html"><![CDATA[Two questions: namespaces and arrays]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=95095#p95095"><![CDATA[
Hello there,<br>I've two small questions, I hope you can help me:<br><br>First, not really important<br>I've a code like this<div class="codebox"><p>Code: </p><pre><code>namespace eval wowa {   variable wchans "test"   variable chars   proc init { args } {      set [namespace current]::chars $::wowa::wchans   }}</code></pre></div>Is there a way to replace <strong class="text-strong">$::wowa::wchans</strong> by an expression as ${[namespace current]}::wchans ?<br><br>Second question, about arrays (in a namespace)<br>I'm trying to get a structure of datas like:<br>chars(me)(0) { "item1" "bla" "item2" "bee" }<br>chars(me)(1) { "item1" "bla" "item2" "bee" }<br>chars(him)(0) { "item1" "bla" "item2" "bee" }<br>chars(him)(1) { "item1" "bla" "item2" "bee" }<br><br>So, I've created this small proc:<div class="codebox"><p>Code: </p><pre><code>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])]"}</code></pre></div>$wdata contains lines:<br>me|test|nothing<br>me|test1|nothing too<br>him|bla|test<br>him|bli|test<br><br>This is completely wrong, anyone has an idea ?<br><br>Thanks a lot.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Tue Nov 16, 2010 8:04 am</p><hr />
]]></content>
	</entry>
	</feed>
