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

	<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-09-25T03:45:52-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Driber]]></name></author>
		<updated>2008-09-25T03:45:52-04:00</updated>

		<published>2008-09-25T03:45:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=85275#p85275</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=85275#p85275"/>
		<title type="html"><![CDATA[string to integer]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=85275#p85275"><![CDATA[
I didn't know tcl automatically does type-casting on variables, so I will give string trim a try<br><br>thanks<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10216">Driber</a> — Thu Sep 25, 2008 3:45 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-09-23T12:51:40-04:00</updated>

		<published>2008-09-23T12:51:40-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=85256#p85256</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=85256#p85256"/>
		<title type="html"><![CDATA[string to integer]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=85256#p85256"><![CDATA[
In this case you might be able to use the <a href="http://www.tcl.tk/man/tcl8.4/TclCmd/expr.htm" class="postlink">expr</a> command. Be aware though that this command may cause some serious security issues if data is not properly sanitized, as all data will be passed through the tcl interpreter.<br><br>Of course, <a href="http://www.tcl.tk/man/tcl8.4/TclCmd/scan.htm" class="postlink">scan</a> would still be an option, with a proper pattern...<br><br>A third option might be to simply strip the string of spaces using <a href="http://www.tcl.tk/man/tcl8.4/TclCmd/string.htm" class="postlink">string trim</a>, as tcl will do the necessary type-casting provided the data makes sense (i.e. string looks like an integer if it only contains digits, as a float if it only contains digits and a single dot, and so on).<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Tue Sep 23, 2008 12:51 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Driber]]></name></author>
		<updated>2008-09-23T04:38:12-04:00</updated>

		<published>2008-09-23T04:38:12-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=85252#p85252</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=85252#p85252"/>
		<title type="html"><![CDATA[string to integer]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=85252#p85252"><![CDATA[
that's not what I'm looking for<br><br>ok here is an example:<br><br>I have $str which contains " 4" (that's a whitespace and a number four)<br><br>I need that string to be converted to an integer so that I can calculate with it<br>for example:<div class="codebox"><p>Code: </p><pre><code>incr str 1</code></pre></div>to make it 5<br><br><br>the php equivalent to this would be:<div class="codebox"><p>Code: </p><pre><code>&lt;?php$str = " 4";$num = (int)$str;?&gt;</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10216">Driber</a> — Tue Sep 23, 2008 4:38 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2008-09-21T09:13:00-04:00</updated>

		<published>2008-09-21T09:13:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=85243#p85243</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=85243#p85243"/>
		<title type="html"><![CDATA[string to integer]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=85243#p85243"><![CDATA[
That would depend on the string in question.. think you could give a couple of examples?<br>In most cases, <a href="http://www.tcl.tk/man/tcl8.4/TclCmd/scan.htm" class="postlink">scan</a> would be your friend however.<br><br>A simple example:<div class="codebox"><p>Code: </p><pre><code>set string "There are 2 users"set int [scan $string "There are %d users"</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Sun Sep 21, 2008 9:13 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Driber]]></name></author>
		<updated>2008-09-21T06:33:19-04:00</updated>

		<published>2008-09-21T06:33:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=85240#p85240</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=85240#p85240"/>
		<title type="html"><![CDATA[string to integer]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=85240#p85240"><![CDATA[
can someone please post an example of how to convert a string to an integer<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10216">Driber</a> — Sun Sep 21, 2008 6:33 am</p><hr />
]]></content>
	</entry>
	</feed>
