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

	<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>2010-09-17T02:41:50-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Elfriede]]></name></author>
		<updated>2010-09-17T02:41:50-04:00</updated>

		<published>2010-09-17T02:41:50-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=94420#p94420</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=94420#p94420"/>
		<title type="html"><![CDATA[How can i remove an empty line within a foreach]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=94420#p94420"><![CDATA[
Thanks @all for the great help <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=9204">Elfriede</a> — Fri Sep 17, 2010 2:41 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[nml375]]></name></author>
		<updated>2010-09-15T15:41:10-04:00</updated>

		<published>2010-09-15T15:41:10-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=94396#p94396</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=94396#p94396"/>
		<title type="html"><![CDATA[How can i remove an empty line within a foreach]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=94396#p94396"><![CDATA[
A few comments on the posted codes:<br>Regular expressions are flexible, but far slower than other kinds of matching.<br>Using llength on a string is a bad idea. In worst case, llength might throw an error due to "improper list", which will immediately terminate the proc.<br>Same goes with using lindex on strings...<br><br>Both $text and $line are strings, not lists. Use the split-command to get a valid list, if you intend to use list operations.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8052">nml375</a> — Wed Sep 15, 2010 3:41 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[speechles]]></name></author>
		<updated>2010-09-15T16:20:09-04:00</updated>

		<published>2010-09-14T12:09:07-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=94381#p94381</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=94381#p94381"/>
		<title type="html"><![CDATA[How can i remove an empty line within a foreach]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=94381#p94381"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>proc some:proc {nick host handle channel text} {   set stext [split $text]   set url [lindex $stext 0]   set result [lindex $stext 1]   set token [::http::geturl $url]   set content [::http::data $token]   ::http::cleanup $token   foreach line [split $content \n] {      set output [string trim [lindex [split $line] 0]]      if {[string length $output]} {         sendmsg $channel "$result $output"      }   }} </code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=8138">speechles</a> — Tue Sep 14, 2010 12:09 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Luminous]]></name></author>
		<updated>2010-09-14T11:33:41-04:00</updated>

		<published>2010-09-14T11:33:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=94380#p94380</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=94380#p94380"/>
		<title type="html"><![CDATA[How can i remove an empty line within a foreach]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=94380#p94380"><![CDATA[
I'd want to test this myself to verify, but that method should be fine, as its checking to see if each line has something. Here's a few more ways I think would work, starting at that foreach loop:<br><br>With a regex:<br><div class="codebox"><p>Code: </p><pre><code>   foreach line [split $content \n] {      if {![regexp {\s+} $line]} {                   sendmsg $channel "$result $output"      }   }} </code></pre></div>With llength:<br><div class="codebox"><p>Code: </p><pre><code>   foreach line [split $content \n] {      if {[llength $line] != 0} {                   sendmsg $channel "$result $output"      }   }}</code></pre></div>Would you mind posting the output of your original as well as how to use it? Also, let us know how those work for you. <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=11101">Luminous</a> — Tue Sep 14, 2010 11:33 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[willyw]]></name></author>
		<updated>2010-09-14T10:57:21-04:00</updated>

		<published>2010-09-14T10:57:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=94377#p94377</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=94377#p94377"/>
		<title type="html"><![CDATA[Re: How can i remove an empty line within a foreach]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=94377#p94377"><![CDATA[
<div class="codebox"><p>Code: </p><pre><code>proc some:proc {nick host handle channel text} {set url [lindex [split $text] 0]set result [lindex $text 1]set token [::http::geturl $url]set content [::http::data $token]::http::cleanup $tokenforeach line [split $content \n] {set output [lindex $line 0]               if {"$output"!=""} {             sendmsg $channel "$result $output"                  }}}</code></pre></div>What happens when you try this?<br>I can't test it, so I'm curious if this simple change is all that is needed.<br><br>Even if this does work ok for you, there very well may be better ways to accomplish it.   It will be interesting to see what else is posted here.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=10420">willyw</a> — Tue Sep 14, 2010 10:57 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Elfriede]]></name></author>
		<updated>2010-09-14T08:31:43-04:00</updated>

		<published>2010-09-14T08:31:43-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=94375#p94375</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=94375#p94375"/>
		<title type="html"><![CDATA[How can i remove an empty line within a foreach]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=94375#p94375"><![CDATA[
Hi everboy <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><br>Im having a small issue and appreciate any help <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_smile.gif" width="15" height="15" alt=":)" title="Smile"><br><div class="codebox"><p>Code: </p><pre><code>proc some:proc {nick host handle channel text} {set url [lindex [split $text] 0]set result [lindex $text 1]set token [::http::geturl $url]set content [::http::data $token]::http::cleanup $tokenforeach line [split $content \n] {set output [lindex $line 0]sendmsg $channel "$result $output"}}</code></pre></div>If the lastline is an emptyline (its not always like this) i get $result without $output, as theres nothing to output. How can i drop that last/empty line ?<br>Thanks!<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=9204">Elfriede</a> — Tue Sep 14, 2010 8:31 am</p><hr />
]]></content>
	</entry>
	</feed>
