<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Oct 31, 2009, at 3:12 PM, András Murányi wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><br><br><div class="gmail_quote">On Sat, Oct 31, 2009 at 7:00 PM, Hans-Christoph Steiner <span dir="ltr">&lt;<a href="mailto:hans@at.or.at">hans@at.or.at</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); margin-top: 0pt; margin-right: 0pt; margin-bottom: 0pt; margin-left: 0.8ex; padding-left: 1ex; position: static; z-index: auto; "> <br> On Oct 30, 2009, at 10:24 PM, Ivica Ico Bukvic wrote:<br> <br> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><blockquote class="gmail_quote" style="border-left-width: 1px; border-left-style: solid; border-left-color: rgb(204, 204, 204); margin-top: 0pt; margin-right: 0pt; margin-bottom: 0pt; margin-left: 0.8ex; padding-left: 1ex; position: static; z-index: auto; "> Hey Ivica,<br> <br> Just make it a global, that's the easiest. &nbsp;Or use namespaces and<br> namespace variables.<br> <br> .hc<br> </blockquote> <br> I am not all that good with tk. Only learned what I had to to hack<br> together better version of <a href="http://pd.tk" target="_blank">pd.tk</a>. Any examples would be most<br> appreciated. How do namespaces work?<br> <br> Also, after opening tons of windows that generate global variables,<br> doesn't this effectively produce a minor but nonetheless present memory<br> leak as the global variables will be hard to trace when deallocating<br> those windows (see my other email re: improvements)?<br> <br> Ico<br> </blockquote> <br> Look at the new pd-gui-rewrite branch, it uses namespaces a fair amount. &nbsp;They are a bit overcomplicated in Tcl, but you don't have to use the complicated parts.<br> <br> .hc<br> <br> </blockquote></div><br>Hans, when you have a few minutes can you just sum up quickly how does it go with namespaces? I've familiarized easy with everything else in the sources, but i couldn't get namespaces do anything (thus my tabbed-console plugin doesn't see the popupmode setting). <br></blockquote><div><br></div><div>Here are the basics:</div><div><br></div><div>Create a namespace 'pdwindow' with the variable 'printout_buffer' in it:</div><div>namespace eval pdwindow {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>variable printout_buffer</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>...</div><div>}</div><div><br></div><div>use the 'printout_buffer' variable anywhere with the namespace prefix:</div><div>puts $::pdwindow::printout_buffer</div><div><br></div><div><br></div><div>Create a proc in the 'pdwindow' namespace and use 'printout_buffer' without the prefix:</div><div><div>proc ::pdwindow::pdtk_post {message} {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>variable printout_buffer</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>puts $printout_buffer</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>...</div><div>}</div><div><br></div><div>Call the pdtk_post proc from anywhere:</div><div><br></div><div>::pdwindow::pdtk_post "blah blah"</div><div><br></div><div>All the pdtk_post proc to be used outside of the 'pdwindow' namespace:</div><div><div>namespace eval pdwindow {</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>...</div><div><span class="Apple-tab-span" style="white-space: pre; ">        </span>namespace export pdtk_post</div></div><div><div><span class="Apple-tab-span" style="white-space:pre">        </span>...</div><div>}</div><div><br></div></div><div>Use the 'pdtk_post' proc from the pdwindow namespace globally without the prefix</div><div><div>namespace import ::pdwindow::pdtk_post</div><div>pdtk_post "blah blah"</div></div></div><div><br></div><br><blockquote type="cite">Btw, i would be happy to clean up pdtk_post as suggested by the comments, but i have questions:<br>- "this should be switchable between Pd window and stderr": how do you imagine this; a command line switch or from preferences...?<br></blockquote><blockquote type="cite">- you mentioned you would shift popupmode to a plugin, is it ok if i give it a shot?<br></blockquote><div><br></div><div>Sure, but I recently fixed those two, thanks to mescalinum's opt_parser code. :) &nbsp;I suppose I should remove the TODO...</div><div><br></div><div>.hc</div></div><div> <span class="Apple-style-span" style="font-size: 12px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><br class="Apple-interchange-newline"><div><br class="khtml-block-placeholder"></div><div><br></div><div>----------------------------------------------------------------------------<br></div><div><br class="khtml-block-placeholder"></div><div>&nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;&nbsp; &nbsp;kill your television</div><br class="Apple-interchange-newline"></div></span> </div><br></body></html>