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

	<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>2001-09-30T19:07:00-04:00</updated>

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

		<entry>
		<author><name><![CDATA[stdragon]]></name></author>
		<updated>2001-09-30T19:07:00-04:00</updated>

		<published>2001-09-30T19:07:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=164#p164</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=164#p164"/>
		<title type="html"><![CDATA[checking if a var is a number or not]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=164#p164"><![CDATA[
If you only want to tell if it's an integer (positive or negative) you could use this:<div class="codebox"><p>Code: </p><pre><code>proc is_integer {x} {  if [catch {incr x}] {return 0}  return 1}</code></pre></div>For a number with a decimal point, you could do a combination of regexp and expr, i.e. check to see that the string is only "+-.[0-9]", then do, if [catch {expr $x + 1}] to see if it's valid (i.e. doesn't have more than one decimal, etc).<div class="codebox"><p>Code: </p><pre><code>proc is_real {x} {  set validchars {^[.+-0123456789].*$}  if ![regexp $validchars $x] {return 0}  if [catch {expr $x + 1}] {return 0}  return 1}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8">stdragon</a> — Sun Sep 30, 2001 7:07 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Petersen]]></name></author>
		<updated>2001-09-30T18:58:00-04:00</updated>

		<published>2001-09-30T18:58:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=163#p163</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=163#p163"/>
		<title type="html"><![CDATA[checking if a var is a number or not]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=163#p163"><![CDATA[
Didn't I already tell you last nite that isnum isn't a valid tcl command (thus it must be a proc on your bot). For tcl versions 8.1 or higher, [string is double $string] would work. And I still can't be bothered working it out for 8.0.x <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":razz:" title="Razz"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=60">Petersen</a> — Sun Sep 30, 2001 6:58 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[greenbear]]></name></author>
		<updated>2001-09-30T17:41:00-04:00</updated>

		<published>2001-09-30T17:41:00-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=162#p162</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=162#p162"/>
		<title type="html"><![CDATA[checking if a var is a number or not]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=162#p162"><![CDATA[
hi, I want to check if a var. is a number or not. until now i have been using isnum, but it doesnt work with negative numbers.<br><br>ie. <br>.tcl isnum 5 -&gt; Tcl: 1<br>.tcl isnum -5 -&gt; Tcl: 0<br><br><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=24">greenbear</a> — Sun Sep 30, 2001 5:41 pm</p><hr />
]]></content>
	</entry>
	</feed>
