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

	<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>2004-07-13T21:28:56-04:00</updated>

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

		<entry>
		<author><name><![CDATA[greenbear]]></name></author>
		<updated>2004-07-13T14:41:29-04:00</updated>

		<published>2004-07-13T14:41:29-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=38582#p38582</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=38582#p38582"/>
		<title type="html"><![CDATA[Saving a variable into a text file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=38582#p38582"><![CDATA[
Here's the code I use to do a backup of a array called 'settings'<div class="codebox"><p>Code: </p><pre><code>set settings_file "settings.dat"proc backup_settings {} { global settings settings_file if {![catch {open $settings_file w} fileid]} {   puts $fileid "### Channel Settings ###"   foreach w [array names settings] {     set setting "[lindex [split [array get settings $w]] 1]"     puts $fileid "set settings($w) $setting"   }   puts $fileid "### EOF Channel Settings ###"   close $fileid   return 1  } else {   putlog "Error: Could not save settings to $settings_file"   return 0 }}</code></pre></div>Then you can just load it on startup like you normally load a tcl, with <div class="codebox"><p>Code: </p><pre><code>source settings.dat</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=24">greenbear</a> — Tue Jul 13, 2004 2:41 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[awyeah]]></name></author>
		<updated>2004-07-13T21:28:56-04:00</updated>

		<published>2004-07-13T12:27:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=38578#p38578</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=38578#p38578"/>
		<title type="html"><![CDATA[Saving a variable into a text file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=38578#p38578"><![CDATA[
You can do something like this.<br><div class="codebox"><p>Code: </p><pre><code>set myfile "data.txt"set myvar "my data here"#To write the variable to the file.set file [open $myfile "a"]puts $file "$myvar"close $file#To read the variableset file [open $myfile "r"]set newvar [gets $file]close $file</code></pre></div>Try reading the FAQ section, with the topic 'BASIC FILE OPERATIONS' in this forum on the other section. It has very useful tips regarding this.<br><br>Anyway, in this case, the data will be written in the first line of the file, and will be appended and overwritten each time (will be replaced), and it will be read from the first line as well.<br><br>I assume you can do the rest, make a procedure and use these codes in your procedure accordingly.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4875">awyeah</a> — Tue Jul 13, 2004 12:27 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Real]]></name></author>
		<updated>2004-07-13T12:09:09-04:00</updated>

		<published>2004-07-13T12:09:09-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=38575#p38575</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=38575#p38575"/>
		<title type="html"><![CDATA[Saving a variable into a text file]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=38575#p38575"><![CDATA[
Well I think the topic says it all doesn't it <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>I've been trying to make the script myself, but it's just too hard for me  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_sad.gif" width="15" height="15" alt=":(" title="Sad"><br>I've also searched on the forum, but nothing seems to work <br><br>So first, I want to write a line in a text file:<br>proc savevar<br>set thevar $text<br>save $thevar in $thisfile (so there should be just 1 line in the text file, this means replacing an other line <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"> )<br><br>Second:<br>I want to make my bot read the file and save the line into a var on every load. <br><br>How can this be done? :/<br><br>Thank you very much<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4669">Real</a> — Tue Jul 13, 2004 12:09 pm</p><hr />
]]></content>
	</entry>
	</feed>
