<?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/21134" />

	<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>2022-03-23T13:22:26-04:00</updated>

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

		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2022-03-23T13:22:26-04:00</updated>

		<published>2022-03-23T13:22:26-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=111039#p111039</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=111039#p111039"/>
		<title type="html"><![CDATA[Accessing a [namespace current] variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=111039#p111039"><![CDATA[
Thanks guys.<br><br>I'll probably use the last method from SpiKe^^ as I'll have to use [namespace parent] sometimes.<br><br>Using upvar is a way I'd looked, but it's less flexible imho<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Wed Mar 23, 2022 1:22 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[SpiKe^^]]></name></author>
		<updated>2022-03-23T12:38:44-04:00</updated>

		<published>2022-03-23T12:38:44-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=111038#p111038</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=111038#p111038"/>
		<title type="html"><![CDATA[Accessing a [namespace current] variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=111038#p111038"><![CDATA[
The common method using [variable] similar to [global]....<div class="codebox"><p>Code: </p><pre><code>    proc readit {} {   ;# common method        variable v       putlog "v is now $v"     } </code></pre></div><br>Another method I find handy....<div class="codebox"><p>Code: </p><pre><code>    proc readit {} {        # another method       putlog "v is now [set [namespace current]::v]"     } </code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=7749">SpiKe^^</a> — Wed Mar 23, 2022 12:38 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[caesar]]></name></author>
		<updated>2022-03-23T12:29:54-04:00</updated>

		<published>2022-03-23T12:29:54-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=111037#p111037</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=111037#p111037"/>
		<title type="html"><![CDATA[Accessing a [namespace current] variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=111037#p111037"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>namespace eval myns {variable vproc doit {} {incr [namespace current]::v}proc readit {} {variable vputlog "v is now $v"   }}</code></pre></div>Or you can use <em class="text-italics">upvar</em>:<div class="codebox"><p>Code: </p><pre><code>namespace eval myns {variable vproc doit {} {incr [namespace current]::v 1}proc readit {} {upvar 1 [namespace current]::v vputlog "v is now $v"   }}</code></pre></div>Btw, there's no need for the '1' in the incr line as by default it increments with one.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=187">caesar</a> — Wed Mar 23, 2022 12:29 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[CrazyCat]]></name></author>
		<updated>2022-03-23T11:36:13-04:00</updated>

		<published>2022-03-23T11:36:13-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=111036#p111036</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=111036#p111036"/>
		<title type="html"><![CDATA[Accessing a [namespace current] variable]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=111036#p111036"><![CDATA[
Hi there,<br><br>I've a little trouble with a script I'm writing. I'm trying to do it really modular with the minimum of hardcoded things.<br><br>The code looks like (just an example):<div class="codebox"><p>Code: </p><pre><code>namespace eval myns {   variable v    proc doit {} {      # This works      incr [namespace current]::v 1   }   proc readit {} {      # this fails      putlog "v is now $[namespace current]::v"   }}</code></pre></div>The proc readit doesn't work, I can't figure out how to access $::myns::v using [namespace current]. All ideas are welcome <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=691">CrazyCat</a> — Wed Mar 23, 2022 11:36 am</p><hr />
]]></content>
	</entry>
	</feed>
