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

	<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>2005-03-19T09:34:38-04:00</updated>

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

		<entry>
		<author><name><![CDATA[awyeah]]></name></author>
		<updated>2005-03-19T09:33:11-04:00</updated>

		<published>2005-03-19T09:33:11-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=47939#p47939</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=47939#p47939"/>
		<title type="html"><![CDATA[help with random number proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=47939#p47939"><![CDATA[
Something like this should do it:<br><div class="codebox"><p>Code: </p><pre><code>set number 0;set list_of_numbers [list];while {$number &lt;= 10} { set temp_number [rand 31]; if {([lsearch -exact $list_of_numbers $temp_number] != -1)} {  lappend list_of_numbers $temp_number  incr number  }}</code></pre></div>or you can use llength to:<br><div class="codebox"><p>Code: </p><pre><code>set list_of_numbers [list];while {[llength $list_of_numbers] &lt;= 10} { set temp_number [rand 31]; if {([lsearch -exact $list_of_numbers $temp_number] != -1)} {  lappend list_of_numbers $temp_number  }}</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=4875">awyeah</a> — Sat Mar 19, 2005 9:33 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[De Kus]]></name></author>
		<updated>2005-03-19T09:34:38-04:00</updated>

		<published>2005-03-19T09:32:28-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=47938#p47938</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=47938#p47938"/>
		<title type="html"><![CDATA[help with random number proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=47938#p47938"><![CDATA[
dont use [join ] on $i, llength is list command, lappend add a list to a list, so no need to convert the list to a string. the only time join makes sense is at the very last '$i' (no need to escape single quotes, they don't have special meaning in TCL), because this is the only time you need your list as string. But since your list contains only numbers as elemtes there should be no diffrenz. but with a bit bad luck llength returns always 1 (which would be always below 10). In my test it at least doesn't.<blockquote class="uncited"><div>[14:08:54] tcl: evaluate (.tcl): llength [join {10 20 1 400}]<br>Tcl: 4</div></blockquote>second, you don't need use "" for numbers, but this should be problem:<blockquote class="uncited"><div>[14:12:17] tcl: evaluate (.tcl):  expr -1 == "-1" &amp;&amp; 1 != "0"<br>Tcl: 1</div></blockquote>lets come to "set i [lappend i $r]"<br>Your are writing 2 times to the same var. but this, too should be no problem:<blockquote class="uncited"><div>[14:29:47] tcl: evaluate (.tcl): set test 1<br>Tcl: 1<br>[14:30:03] tcl: evaluate (.tcl): set test [lappend test 2]<br>Tcl: 1 2</div></blockquote>So I see 3 things that look suspicious, but none I can confirm to be the problem.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2382">De Kus</a> — Sat Mar 19, 2005 9:32 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[blotter45]]></name></author>
		<updated>2005-03-19T08:03:41-04:00</updated>

		<published>2005-03-19T08:03:41-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=47933#p47933</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=47933#p47933"/>
		<title type="html"><![CDATA[help with random number proc]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=47933#p47933"><![CDATA[
Hiya <img class="smilies" src="https://forum.eggheads.org/images/smilies/icon_wink.gif" width="15" height="15" alt=";)" title="Wink"><br><br>I'm trying to make a proc to output a string of random numbers, based on a given limit.<br><div class="codebox"><p>Code: </p><pre><code>bind dcc o|- otrandset ot:randset#number of random questions to pick each time a test is begunset ot_var(qlimit) "10"proc ot:total { } {  # returns the number of total questions  global ot_q  return [array size ot_q]}proc ot:randset { hand idx arg } {  global ot_var  if {![valididx $idx]} {    return 0  }  set tot [ot:total]  set i ""  while {[llength [join $i]] &lt;= $ot_var(qlimit)} {    set r [rand $tot]    if {[lsearch [join $i] $r] == "-1" &amp;&amp; $r != "0"} {      set i [lappend i $r]    } else {      continue    }  }  putdcc $idx "[llength [join $i]] random numbers: \'$i\'"  return 0}</code></pre></div>So for example if there are 30 total questions, that proc should output a list of 10 random question numbers, but only if the number isn't already in the list, and only if the number is not zero. But the above proc just hangs when run.. Any suggestions?<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=6025">blotter45</a> — Sat Mar 19, 2005 8:03 am</p><hr />
]]></content>
	</entry>
	</feed>
