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

	<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>2012-07-13T19:20:16-04:00</updated>

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

		<entry>
		<author><name><![CDATA[PacMan1973]]></name></author>
		<updated>2012-06-08T03:19:43-04:00</updated>

		<published>2012-06-08T03:19:43-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99579#p99579</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99579#p99579"/>
		<title type="html"><![CDATA[Ignoring zeros?]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99579#p99579"><![CDATA[
Hey guys,<br><br>did anybody ever try to calculate something like 5/100 or 5/100000...?<br><br><br>&lt;Pac-Man&gt; !calc 5/100<br>&lt;eggdrop&gt; 5/100000 = 0.5<br><br>&lt;Pac-Man&gt; !calc 5/100000<br>&lt;eggdrop&gt; 5/100000 = 0.5<br><br><br>Any ideas, how to fix it?  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_eek.gif" width="15" height="15" alt=":shock:" title="Shocked"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=12010">PacMan1973</a> — Fri Jun 08, 2012 3:19 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[spithash]]></name></author>
		<updated>2012-04-12T01:21:48-04:00</updated>

		<published>2012-04-12T01:21:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99180#p99180</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99180#p99180"/>
		<title type="html"><![CDATA[Simple calculator.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99180#p99180"><![CDATA[
yeah FightingNavyman, it doesn't do unicode (utf8) that's exactly why I asked if it's possible  <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9145">spithash</a> — Thu Apr 12, 2012 1:21 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[FightingNavyman]]></name></author>
		<updated>2012-04-10T01:07:08-04:00</updated>

		<published>2012-04-10T01:07:08-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99177#p99177</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99177#p99177"/>
		<title type="html"><![CDATA[Simple calculator.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99177#p99177"><![CDATA[
<strong class="text-strong">spithash said</strong>: I wonder if this script can do unicode char mathematics, like, for example:<br><br>results are: <br>&lt;~chachin&gt; !calc (1+√(5))/2<br>[12:05:40am] &lt;@R2D2&gt; chachin: Invalid expression. Cannot calculate ''.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11503">FightingNavyman</a> — Tue Apr 10, 2012 1:07 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[spithash]]></name></author>
		<updated>2012-04-09T19:58:31-04:00</updated>

		<published>2012-04-09T19:58:31-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99176#p99176</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99176#p99176"/>
		<title type="html"><![CDATA[Simple calculator.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99176#p99176"><![CDATA[
I wonder if this script can do unicode char mathematics, like, for example: <br><br>!calc (1+√(5))/2<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9145">spithash</a> — Mon Apr 09, 2012 7:58 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[spithash]]></name></author>
		<updated>2012-04-09T04:18:25-04:00</updated>

		<published>2012-04-09T04:18:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99173#p99173</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99173#p99173"/>
		<title type="html"><![CDATA[Simple calculator.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99173#p99173"><![CDATA[
this script is awesome. I'm so copying it. thank you guys <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9145">spithash</a> — Mon Apr 09, 2012 4:18 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2012-07-13T19:20:16-04:00</updated>

		<published>2012-04-07T03:24:27-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99170#p99170</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99170#p99170"/>
		<title type="html"><![CDATA[Simple calculator.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99170#p99170"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code># this is the maximum amount of digits# that will be shown after the decimal pointset calc_precision 7bind pub - !calc safe_calcbind pub - .calc safe_calcsetudef flag calcproc is_op {str} {return [expr [lsearch {{ } . + - * ^ / ( ) %} $str] != -1]}proc safe_calc {nick uhost hand chan str} {if {![channel get $chan calc]} { return }foreach char [split $str {}] {if {![is_op $char] &amp;&amp; ![string is integer $char]} {putserv "PRIVMSG $chan :$nick: Invalid expression. Cannot calculate '$char'."return}}if {[catch {format "%.${::calc_precision}f" [expr [calc_force_floats $str]]} out]} {putserv "PRIVMSG $chan :$nick: Invalid equation. Cannot calculate."return} else {putserv "PRIVMSG $chan :$str = [calc_precision_format $out]"}}proc calc_precision_format {value} {      set v [split $value .]      set v1 [lindex $v 0]      set v2 [string trim [lindex $v 1] " 0"]      if {[string length $v2]} { set v "${v1}.${v2}" } { set v $v1 }}proc calc_force_floats {equation} {   regsub -all -- {[0-9.]+} $equation "double(\\0)" equation   return $equation} putlog "calculate loaded."# eof</code></pre></div><blockquote class="uncited"><div>&lt;speechles&gt; !calc [die]<br>&lt;sp33chy&gt; speechles: Invalid expression. Cannot calculate '['.<br>&lt;speechles&gt; !calc -2.02 + 3.112312 * 0.2<br>&lt;sp33chy&gt; -2.02 + 3.112312 * 0.2 = -1.3975376<br>&lt;speechles&gt; !calc 5 + 3 + 2.1<br>&lt;sp33chy&gt; 5 + 3 + 2.1 = 10.1<br>&lt;speechles&gt; !calc 5 + 3 + 2<br>&lt;sp33chy&gt; 5 + 3 + 2 = 10<br>&lt;speechles&gt; !calc 5 + 3 + 2 + M<br>&lt;sp33chy&gt; speechles: Invalid expression. Cannot calculate 'M'.<br><br>-- These last two demonstrate how precision affects results ---<br>&lt;speechles&gt; !calc 2.000005+9.38712317823781287817237812789378912318923*5<br>&lt;sp33chy&gt; 2.000005+9.38712317823781287817237812789378912318923*5 = 48.9356209<br>&lt;speechles&gt; !calc 48.9356209 - 5*9.38712317823781287817237812789378912318923<br>&lt;sp33chy&gt; 48.9356209 - 5*9.38712317823781287817237812789378912318923 = 2.5<br><br>That should be "2.000005" but because we restrict precision to 7, we wind up off by .5 or so .. This is normal because we create the condition by stripping excess digits. You need to take this into account when you set your precision. 7 seems a good number. Maybe 8 is better. Who knows?</div></blockquote>Enjoys ;^)<br><br>Uses same procedures used to modify other script to same behavior.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Sat Apr 07, 2012 3:24 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Gewan]]></name></author>
		<updated>2012-04-04T17:06:24-04:00</updated>

		<published>2012-04-04T17:06:24-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=99164#p99164</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=99164#p99164"/>
		<title type="html"><![CDATA[Something messed up]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=99164#p99164"><![CDATA[
Script has worked flawlessly over the years.<br>However, now something's messed up.<br>I'm not sure if auto-updates ('Buntu) over apt-get has caused it.<br>Anyhow, with my latest revision, all !c requests yields answers in /MSG.<br>I was dazed and angry and worked my way for a solution -- empty handed.<br>Niow, I found <a href="https://github.com/horgh/eggdrop-scripts/blob/master/calc.tcl" class="postlink">this simple script</a> that <span style="text-decoration:underline">may</span> be a better scratch than the one we used.<br>It works nice (decimals and all) by default, but it's adding ".0" for integers.<br>Is there any easy way to modify this script so that it returns integers without .0 and I would fly of happyness! :&gt;<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11468">Gewan</a> — Wed Apr 04, 2012 5:06 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Gewan]]></name></author>
		<updated>2011-03-09T11:34:19-04:00</updated>

		<published>2011-03-09T11:34:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96420#p96420</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96420#p96420"/>
		<title type="html"><![CDATA[Simple calculator.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96420#p96420"><![CDATA[
It works like a charm! <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_biggrin.gif" width="15" height="15" alt=":D" title="Very Happy"><br>Thanks a lot!<br><br>Cheers~<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11468">Gewan</a> — Wed Mar 09, 2011 11:34 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2011-03-09T11:19:19-04:00</updated>

		<published>2011-03-09T11:19:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96419#p96419</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96419#p96419"/>
		<title type="html"><![CDATA[Simple calculator.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96419#p96419"><![CDATA[
<blockquote class="uncited"><div><strong class="text-strong">Thanks alot</strong> for your effort speechles. I'm so thankful.<br>Some minor flaw though, from what it seems.<br><br><em class="text-italics">&lt;Gewan&gt; !c 1+2<br>&lt;Eggdrop&gt; error calculating '1+2' (can't read "::": no such variable)</em><br><br>Getting the same respons with 1-2, 1/2, or even 1*2.<br><br>Ideas?</div></blockquote>That was a flaw in my code. I've corrected that, you can now safely use the above code changes and they will function correctly. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>Enjoys, and have a fun <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_razz.gif" width="15" height="15" alt=":P" title="Razz"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Wed Mar 09, 2011 11:19 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Gewan]]></name></author>
		<updated>2011-03-09T10:42:48-04:00</updated>

		<published>2011-03-09T10:42:48-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96418#p96418</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96418#p96418"/>
		<title type="html"><![CDATA[Simple calculator.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96418#p96418"><![CDATA[
<strong class="text-strong">Thanks alot</strong> for your effort speechles. I'm so thankful.<br>Some minor flaw though, from what it seems.<br><br><em class="text-italics">&lt;Gewan&gt; !c 1+2<br>&lt;Eggdrop&gt; error calculating '1+2' (can't read "::": no such variable)</em><br><br>Getting the same respons with 1-2, 1/2, or even 1*2.<br><br>Ideas?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11468">Gewan</a> — Wed Mar 09, 2011 10:42 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2011-03-09T11:20:18-04:00</updated>

		<published>2011-03-08T22:46:51-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96412#p96412</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96412#p96412"/>
		<title type="html"><![CDATA[Simple calculator.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96412#p96412"><![CDATA[
<blockquote class="uncited"><div>So, anyone feeling bored? Please make me a "calc_mod.tcl" that will add the "." (in either numerator or denominator) per default. I would be _very_ happy! <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"></div></blockquote>Using the original script make these simple modifications:<div class="codebox"><p>Code: </p><pre><code>change this:            } elseif {[catch {expr [calc_fixexpr $remainder]} output]} {to this:            } elseif {[catch {set output [format "%.${::calc_precision}f" [expr [calc_fixexpr [calc_force_floats $remainder]]]]} output]} {change this:            calc_msg $output2 "$remainder = $output"to this:            calc_msg $output2 "$remainder = [calc_precision_format $output]"then add these procedures to the end:proc calc_precision_format {value} {set v [split $value .]set v1 [lindex $v 0]set v2 [string trim [lindex $v 1] " 0"]if {[string length $v2]} { set v "${v1}.${v2}" } { set v $v1 }}proc calc_force_floats {equation} {regsub -all -- {[0-9.]+} $equation "double(\\0)" equationreturn $equation}then add this to the very top of the script:# set the digits of precision you want in your displayset calc_precision 7</code></pre></div>This will remove the ending 0's, as well as the decimal point when not needed. Using the variable calc_precision you control how many digits will be the maximum after the decimal point. If this looks familiar, yes, this is the exact same technique used within Incith:Weather. <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><br>You will never see things like ( 7.0200000 or 7.0000000 ) .. These will instead be displayed as ( 7.02 or 7 ) respectively. This is because even though you've set calc_precision to 7, it will smartly clean the number up before displaying to remove needless precision.<br><br>Try this out and see if it works <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><br><br>edit: corrected issue mentioned below....<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Tue Mar 08, 2011 10:46 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Gewan]]></name></author>
		<updated>2011-03-08T16:05:32-04:00</updated>

		<published>2011-03-08T16:05:32-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96406#p96406</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96406#p96406"/>
		<title type="html"><![CDATA[Erhm.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96406#p96406"><![CDATA[
Hi (again).<br>Guys. Regarding <a href="http://briped.net/2007/06/20/calctcl/" class="postlink"><strong class="text-strong">calc.tcl</strong></a> now.<br><br><em class="text-italics">&lt;@NejthanX&gt; !c 123/5<br>&lt;@Eggdrop&gt; 123/5 = 24<br><br>&lt;@Gewan&gt; !c 123/5.<br>&lt;@Eggdrop&gt; 123/5. = 24.6<br><br>&lt;@Gewan&gt; !c 123./5<br>&lt;@Eggdrop&gt; 123/5. = 24.6</em><br><br>It won't even round off per default, but just omit the decimals, see. Adding a simple dot will make it return correct answer. Any chance that anyone here could modify calc.tcl so that it add the dot auto matically? When I'm tired I forget to add the dot, and I'm too slow/dumb to always "see" when decimals are to be expected in a result (please don't judge me).<br><br>So, anyone feeling bored? Please make me a "calc_mod.tcl" that will add the "." (in either numerator or denominator) per default. I would be _very_ happy! <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11468">Gewan</a> — Tue Mar 08, 2011 4:05 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Gewan]]></name></author>
		<updated>2011-03-06T15:16:22-04:00</updated>

		<published>2011-03-06T15:16:22-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96344#p96344</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96344#p96344"/>
		<title type="html"><![CDATA[Simple calculator.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96344#p96344"><![CDATA[
<strong class="text-strong">@arfer,<br></strong>Thank you very much for you taking the time to check the script. Very kind.<br>I tried copying the script again, pasting it into vim. Same error again though :/<br>It works fine without use of decimals, but the 123/2.0 won't fly.<br><br>Also, for your information:<br><br><em class="text-italics">I am Eggdrop, running eggdrop v1.6.19+ctcpfix: 6 users (mem: 267k).<br>Tcl version: 8.4.19 (header version 8.4.19)<br></em><br><br><br><strong class="text-strong">--EDIT--</strong><br>Guys! Never mind this.<br>I did a simple .restart and guess what?<br>Yeah, it now works like a charm.<br>Thanks for all your help!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11468">Gewan</a> — Sun Mar 06, 2011 3:16 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[arfer]]></name></author>
		<updated>2011-03-06T08:56:04-04:00</updated>

		<published>2011-03-06T08:56:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96339#p96339</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96339#p96339"/>
		<title type="html"><![CDATA[Simple calculator.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96339#p96339"><![CDATA[
I copied the script calc.tcl directly from the site you pasted above and loaded it into one of my bots. It seems to work fine for me.<br><br>[12:44] &lt;@arfer&gt; .calc 123/2<br>[12:44] &lt;Colossus&gt; 123/2 = 61<br>[12:44] &lt;@arfer&gt; .calc 123/2.0<br>[12:44] &lt;Colossus&gt; 123/2.0 = 61.5<br><br>The script is on an Eggdrop version 1.6.20 using Tcl 8.5<br><br>There is some discussion on google regarding the script but this is more to do with the difference in default decimal precision between Tcl 8.4 and Tcl 8.5, rather than the generation of errors.<br><br>Hopefully somebody following this thread will recognise the exact error and point you in the right direction. I would download the file again and ensure that you use a competent text editor to read/modify it. I suggest you do not modify it in any way until you have established whether or not it works for you as is.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=5705">arfer</a> — Sun Mar 06, 2011 8:56 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Gewan]]></name></author>
		<updated>2011-03-06T07:16:25-04:00</updated>

		<published>2011-03-06T07:16:25-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=96338#p96338</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=96338#p96338"/>
		<title type="html"><![CDATA[Simple calculator.]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=96338#p96338"><![CDATA[
<strong class="text-strong">@arfer,</strong><br><br>I see, pardon me. Then I change approach to officially request for a script/modification of calc.tcl that will be able to handle decimals.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=11468">Gewan</a> — Sun Mar 06, 2011 7:16 am</p><hr />
]]></content>
	</entry>
	</feed>
