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

	<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>2003-06-05T20:19:46-04:00</updated>

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

		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2003-06-05T20:19:46-04:00</updated>

		<published>2003-06-05T20:19:46-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=21312#p21312</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=21312#p21312"/>
		<title type="html"><![CDATA[variable backup in file..]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=21312#p21312"><![CDATA[
In tcl, there are no multidimensional arrays. When you say blah(word1,word2) that is actually a single entry called "word1,word2", which is a perfectly valid name. If you say blah(word1) it will not return a new array (as a real multidimensional array would).<br><br>Anyway, I'll go ahead and update this code a bit, this should work, although I haven't tested it:<br><div class="codebox"><p>Code: </p><pre><code>proc write_array {name file} {   set fp [open $file w]   puts $fp [uplevel 1 [list array get $name]]  close $fp } proc read_array {name file} {   set fp [open $file r]   uplevel 1 [list array set $name [read -nonewline $fp]]  close $fp }</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Thu Jun 05, 2003 8:19 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[GodOfSuicide]]></name></author>
		<updated>2003-06-05T10:42:25-04:00</updated>

		<published>2003-06-05T10:42:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=21293#p21293</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=21293#p21293"/>
		<title type="html"><![CDATA[variable backup in file..]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=21293#p21293"><![CDATA[
does this also work for multiple arrays (like myvar(name,date)) ?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1433">GodOfSuicide</a> — Thu Jun 05, 2003 10:42 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-06-03T16:49:19-04:00</updated>

		<published>2003-06-03T16:49:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=21194#p21194</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=21194#p21194"/>
		<title type="html"><![CDATA[variable backup in file..]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=21194#p21194"><![CDATA[
True.<br><br>However, namespaces and the upvar commands are the two I am trying to work on, upvar I have never had use for.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Tue Jun 03, 2003 4:49 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2003-06-03T15:48:32-04:00</updated>

		<published>2003-06-03T15:48:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=21192#p21192</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=21192#p21192"/>
		<title type="html"><![CDATA[variable backup in file..]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=21192#p21192"><![CDATA[
ppslim give me some credit! I think you misunderstood what I said. Uplevel works just like eval, right? So it's not very safe to read in text and simply eval it. If there is a stray line with [blah blah] it will try to execute it. Now, if the person *only* uses write_array to write the file, it's not too bad, because it will escape those characters.<br><br>That said, I just realized the code doesn't even work. The 'array set' command expects a list as a single variable, e.g. <ul><li>. The code as stated, since it evaluates the *result* of [read] rather than the [read] itself, will make each thing a separate argument rather than a list element. This will call the command with too many arguments.<br><br>Perhaps I have been away too long if you've forgotten to put such things in a <ul> <li>construct rather than just quotes :) This is the same sort of problem that occurs when people say utimer "putserv $blah" rather than utimer [list putserv $blah].<br><br>Anyway, it's easier and more efficient to use the upvar command rather than have tcl create all these lists.</li></ul></li></ul><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Tue Jun 03, 2003 3:48 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-06-03T15:19:27-04:00</updated>

		<published>2003-06-03T15:19:27-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=21190#p21190</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=21190#p21190"/>
		<title type="html"><![CDATA[variable backup in file..]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=21190#p21190"><![CDATA[
No, thats why I used quotes and not brackets.<br><br>Damn, you can't have been away that long  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_rolleyes.gif" width="15" height="15" alt=":roll:" title="Rolling Eyes"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Tue Jun 03, 2003 3:19 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2003-06-03T15:14:31-04:00</updated>

		<published>2003-06-03T15:14:31-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=21189#p21189</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=21189#p21189"/>
		<title type="html"><![CDATA[variable backup in file..]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=21189#p21189"><![CDATA[
ppslim, one problem with your code: in read_array you're passing the result of [read] to uplevel to be evaluated (since you used quotes). Maybe a better way is to use upvar?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Tue Jun 03, 2003 3:14 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2003-06-03T14:42:59-04:00</updated>

		<published>2003-06-03T14:42:59-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=21187#p21187</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=21187#p21187"/>
		<title type="html"><![CDATA[variable backup in file..]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=21187#p21187"><![CDATA[
Tcl arrays (they are infact hash lists) can be written to file easily.<br><div class="codebox"><p>Code: </p><pre><code>proc write_array {name file} {  set fp [open $file w]  puts $fp [uplevel 1 "array get $name"]  close $fp}proc read_array {name file} {  set fp [open $file r]  uplevel 1 "array set $name [read -nonewline $fp]"  close $fp}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Tue Jun 03, 2003 2:42 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[GodOfSuicide]]></name></author>
		<updated>2003-06-03T12:50:54-04:00</updated>

		<published>2003-06-03T12:50:54-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=21184#p21184</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=21184#p21184"/>
		<title type="html"><![CDATA[variable backup in file..]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=21184#p21184"><![CDATA[
Hi..<br><br>i've got a quite big var (array), and i'd need to backup cos this data is lost if the bot crashes / restarts / etc<br><br>if there a way to write a var into a file and write it back again ?<br>like delphi<div class="codebox"><p>Code: </p><pre><code>write :for i := 0 to my_array.items.count -1 do my_memo.lines.add(my_array.item[i])get :for i := 0 to my_memo.lines.count -1 do my_array.item[i] := memo1.lines[i]</code></pre></div>The array isn't myvar(1) myvar(2) but myvar(word) myvar(anotherword) and so on.<br><br>I'd like to dump this var into a txt file and if the bot restarts it should write the var based onto the data in this txt.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1433">GodOfSuicide</a> — Tue Jun 03, 2003 12:50 pm</p><hr />
]]></content>
	</entry>
	</feed>
