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

	<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>2002-10-24T17:29:04-04:00</updated>

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

		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2002-10-24T17:29:04-04:00</updated>

		<published>2002-10-24T17:29:04-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12334#p12334</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12334#p12334"/>
		<title type="html"><![CDATA[Passing Arrays to and from a procedure]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12334#p12334"><![CDATA[
Thanks for the examples guys! <br><br>I also come from a php background which is why I was having so much trouble understanding arrays in tcl. <br><br>BTW, I found a great explanation <a href="http://mailweb.udlap.mx/~sistemas/tlatoa/courses/Tcl.html" class="postlink">here</a>.<br><br>Thanks again,<br><br>Juno<p>Statistics: Posted by Guest — Thu Oct 24, 2002 5:29 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2002-10-24T11:45:52-04:00</updated>

		<published>2002-10-24T11:45:52-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12303#p12303</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12303#p12303"/>
		<title type="html"><![CDATA[Passing Arrays to and from a procedure]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12303#p12303"><![CDATA[
OOPS - I am have been seeling with too many PHP script lately.<br><br>There is that option, but the actual one I was aiming at, which will provide the protection I was talking about is.<br><div class="codebox"><p>Code: </p><pre><code>proc test5 {input1 input2} {  puts stdout "STANDARD VAR: $input1"  array set arr $input2  foreach a [array names $arr] {    puts stdout "ARRAY: name = $a : value = $arr($a)"  }}test5 "hello" [array get arr]</code></pre></div>This would allow the array to be passed over the proc arguments, as my first example had intended. It's entirly up to you how you do it.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Thu Oct 24, 2002 11:45 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[strikelight]]></name></author>
		<updated>2002-10-24T10:36:47-04:00</updated>

		<published>2002-10-24T10:36:47-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12293#p12293</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12293#p12293"/>
		<title type="html"><![CDATA[Passing Arrays to and from a procedure]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12293#p12293"><![CDATA[
<blockquote class="uncited"><div>Arrays can be passed to and from procedures with ease, and don't need any special treatment.<br><br>See netbots.tcl for a lot of helpful examples of this. Something like the following.<br><div class="codebox"><p>Code: </p><pre><code>set arr(item1) "value2"set arr(item3) "value4"proc test5 {input1 input2} {  puts stdout "STANDARD VAR: $input1"  foreach a [array names input2] {    puts stdout "ARRAY: name = $a : value = $input2($a)"  }}proc test6 {input1} {  global arr  puts stdout "STANDARD VAR: $input1"  foreach a [array names arr] {    puts stdout "ARRAY: name = $a : value = $arr($a)"  }}test5 "hello" $arrtest6 "hello"</code></pre></div>Both the test5 and test6 procedure output the same thing, the only differance being,t he way these arrays are passed.<br><br>test5 is genraly safer, as you can modify the values within the array, without them becoming global.</div></blockquote>Doing this (for test5) would only generate a 'can't read "arr": variable is array' error.<br>What I think you may have meant is the following:<br><div class="codebox"><p>Code: </p><pre><code>proc test5 {input1 input2} {  global $input2 ;# ofcourse, the array needs to be set globally  puts stdout "STANDARD VAR: $input1"  foreach a [array names $input2] {    puts stdout "ARRAY: name = $a : value = [lindex [array get $input2 $a] 1]" ;# split not needed since array get already returns a -list-  }}  </code></pre></div>And to be called with a string representing the array name, such as:<br><div class="codebox"><p>Code: </p><pre><code>test5 "hello" "arr"</code></pre></div><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2005">strikelight</a> — Thu Oct 24, 2002 10:36 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[ppslim]]></name></author>
		<updated>2002-10-24T04:27:33-04:00</updated>

		<published>2002-10-24T04:27:33-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12266#p12266</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12266#p12266"/>
		<title type="html"><![CDATA[Passing Arrays to and from a procedure]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12266#p12266"><![CDATA[
Arrays can be passed to and from procedures with ease, and don't need any special treatment.<br><br>See netbots.tcl for a lot of helpful examples of this. Something like the following.<br><div class="codebox"><p>Code: </p><pre><code>set arr(item1) "value2"set arr(item3) "value4"proc test5 {input1 input2} {  puts stdout "STANDARD VAR: $input1"  foreach a [array names input2] {    puts stdout "ARRAY: name = $a : value = $input2($a)"  }}proc test6 {input1} {  global arr  puts stdout "STANDARD VAR: $input1"  foreach a [array names arr] {    puts stdout "ARRAY: name = $a : value = $arr($a)"  }}test5 "hello" $arrtest6 "hello"</code></pre></div>Both the test5 and test6 procedure output the same thing, the only differance being,t he way these arrays are passed.<br><br>test5 is genraly safer, as you can modify the values within the array, without them becoming global.<p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=2">ppslim</a> — Thu Oct 24, 2002 4:27 am</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[tainted]]></name></author>
		<updated>2002-10-23T23:49:01-04:00</updated>

		<published>2002-10-23T23:49:01-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12258#p12258</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12258#p12258"/>
		<title type="html"><![CDATA[Passing Arrays to and from a procedure]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12258#p12258"><![CDATA[
I'm not too sure exactly what you are trying to do, but here is a link for documentation on 'upvar' and the rest of the tcl commands. tcl-commands.txt or whatever comes with eggdrop only lists the eggdrop specific commands and their uses. <a href="http://www.tcl.tk/man/" class="postlink">http://www.tcl.tk/man/</a><p>Statistics: Posted by <a href="https://forum.eggheads.org/memberlist.php?mode=viewprofile&amp;u=1256">tainted</a> — Wed Oct 23, 2002 11:49 pm</p><hr />
]]></content>
	</entry>
		<entry>
		<author><name><![CDATA[Anonymous]]></name></author>
		<updated>2002-10-23T20:41:21-04:00</updated>

		<published>2002-10-23T20:41:21-04:00</published>
		<id>https://forum.eggheads.org/viewtopic.php?p=12255#p12255</id>
		<link href="https://forum.eggheads.org/viewtopic.php?p=12255#p12255"/>
		<title type="html"><![CDATA[Passing Arrays to and from a procedure]]></title>

		
		<content type="html" xml:base="https://forum.eggheads.org/viewtopic.php?p=12255#p12255"><![CDATA[
Hi,<br>I'm new to tcl and I'm having trouble passing arrays to and from procedures. I know it has something to do with upvar, but I can't find any documentation on it. Could someone please give an example?<br><br><br>Thanks,<br><br>Juno<p>Statistics: Posted by Guest — Wed Oct 23, 2002 8:41 pm</p><hr />
]]></content>
	</entry>
	</feed>
