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

	<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>2008-06-07T11:41:32-04:00</updated>

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

		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-06-07T11:41:32-04:00</updated>

		<published>2008-06-07T11:41:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83443#p83443</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83443#p83443"/>
		<title type="html"><![CDATA[Make a string survive rehashing...]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83443#p83443"><![CDATA[
You could also save the variables automatically, using something like this.<br>In this case, you use <strong class="text-strong">register_savevar</strong> to tell the script which global variables to save.<div class="codebox"><p>Code: </p><pre><code>bind evnt - "prerehash" save_rehashbind evnt - "prerestart" save_rehashproc save_rehash {evnt} { if {[info exists ::savevars]} {  savevars "./botname.savevars" $::savevars }}proc register_savevar {var} { if {!([info exists ::savevars] &amp;&amp; [lsearch -exact $::savevars $var])} {  lappend ::savevars $var }}</code></pre></div>The following modifications to <strong class="text-strong">savevars</strong> is also recommended, in order to handle non-existent variables.<div class="codebox"><p>Code: </p><pre><code>proc savevars {file varlist} { set fId [open $file "WRONLY CREAT TRUNC"] foreach var $varlist {  upvar #0 $var tmp  if {[info exists tmp]} {   puts $fId [list set $var $tmp]  } } close $fId}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sat Jun 07, 2008 11:41 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-06-06T21:27:28-04:00</updated>

		<published>2008-06-06T21:27:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83440#p83440</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83440#p83440"/>
		<title type="html"><![CDATA[Make a string survive rehashing...]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83440#p83440"><![CDATA[
There are a few various techniques to accomplish that. If your intention is to restore the value of a variable, you might be able to use something like this:<div class="codebox"><p>Code: </p><pre><code>proc savevars {file varlist} { set fId [open $file "WRONLY CREAT TRUNC"] foreach var $varlist {  upvar #0 $var tmp  puts $fId [list set $var $tmp] } close $fId}</code></pre></div>Then, all you have to do to save is call savevars with the file to store variables in, and the list of variables to save, and load the savefile as a normal script to restore:<br><div class="codebox"><p>Code: </p><pre><code>#save var1, var2, and var3 in myvars.savesavevars "./myvars.save" [list var1 var2 var3]#Restore saved valuesif {[file exists "./myvars.save"]} {source ./myvars.save}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Fri Jun 06, 2008 9:27 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Nimos]]></name></author>
		<updated>2008-06-06T19:15:40-04:00</updated>

		<published>2008-06-06T19:15:40-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=83439#p83439</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=83439#p83439"/>
		<title type="html"><![CDATA[Make a string survive rehashing...]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=83439#p83439"><![CDATA[
how can I write something into a file, and reload it after rehashing?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9877">Nimos</a> — Fri Jun 06, 2008 7:15 pm</p><hr />
]]></content>
	</entry>
	</feed>
