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

	<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-03-08T05:09:19-04:00</updated>

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

		<entry>
		<author><name><![CDATA[incith]]></name></author>
		<updated>2008-03-08T05:09:19-04:00</updated>

		<published>2008-03-08T05:09:19-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=81532#p81532</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=81532#p81532"/>
		<title type="html"><![CDATA[Help me clean up my line_wrap/parse_output procs]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=81532#p81532"><![CDATA[
Well, I'd like to get this into 1 single proc hopefully.  I use these for splitting long lines, and detecting what the seperator is, if it's \n then we will want to split on \n and push out 1 line per \n.<br><br>If the seperator is not \n, then we want to just split on the $split_length.<br><br>line_wrap itself works great, but I was never able/could be bothered to merge parse_output into it, and it became a little messy.  Here are the procs:<div class="codebox"><p>Code: </p><pre><code>    # [parse_output] : prepares output for sending to a channel/user, calls line_wrap    #    proc parse_output {input} {      set parsed_output [set parsed_current {}]      if {[string match "\n" $incith::layout::seperator] == 1} {        regsub {\n\s*$} $input "" input        foreach newline [split $input "\n"] {          foreach line [incith::layout::line_wrap $newline] {            lappend parsed_output $line          }        }      } else {        regsub "(?:${incith::layout::seperator}|\\|)\\s*$" $input {} input        foreach line [incith::layout::line_wrap $input] {          lappend parsed_output $line        }      }      return $parsed_output    }    # [line_wrap] : takes a long line in, and chops it before the specified length    # http://forum.egghelp.org/viewtopic.php?t=6690    #    proc line_wrap {str {splitChr { }}} {      set out [set cur {}]      set i 0      set len $incith::layout::split_length      foreach word [split [set str][set str ""] $splitChr] {        if {[incr i [string len $word]] &gt; $len} {          lappend out [join $cur $splitChr]          set cur [list $word]          set i [string len $word]        } else {          lappend cur $word        }        incr i      }      lappend out [join $cur $splitChr]    }</code></pre></div>And then I'd call it with this:<div class="codebox"><p>Code: </p><pre><code>    # [send_output] : sends $data appropriately out to $where    #    proc send_output {where data} {      if {${incith::layout::notices} &gt;= 1 &amp;&amp; ![string match {#*} $where]} {        foreach line [incith::layout::parse_output $data] {          putquick "NOTICE $where :${line}"        }      } else {        foreach line [incith::layout::parse_output $data] {          putquick "PRIVMSG $where :${line}"        }      }    }</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6130">incith</a> — Sat Mar 08, 2008 5:09 am</p><hr />
]]></content>
	</entry>
	</feed>
