<?xml version="1.0"?>
<rss version="2.0">
	<channel>
		<title>Name input question</title>
		<link>http://www.allegro.cc/forums/view/589889</link>
		<description>Allegro.cc Forum Thread</description>
		<webMaster>matthew@allegro.cc (Matthew Leverton)</webMaster>
		<lastBuildDate>Sun, 04 Feb 2007 22:42:40 +0000</lastBuildDate>
	</channel>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>So, my game runs smoothly, the highscore table works fine (except that for some reason, it shows 1 entry too much... last entry&#39;s always double, but that left aside), but now I want the player to enter his/her name, so it can store that into the highscore table instead of a standard string.</p><p>Anybody here know how I can get around to do this? preferably, it&#39;d be an input-field that&#39;s drawn on the screen. I simply have no idea how to start on this:-X
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Raf Vermeulen)</author>
		<pubDate>Sun, 04 Feb 2007 09:46:38 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p><a href="http://www.allegro.cc/forums/thread/589861">This thread</a> is going on right now with someone creating a text input class.</p><p>Basic concept:<br />---Read a key,<br />------if its valid(a letter or whatever they can type in)<br />---------add it to a string/buffer<br />------if its not valid<br />---------discard it<br />------if key is backspace<br />---------remove the last character on the string/buffer<br />---Display it to the screen</p><p><a href="http://www.allegro.cc/manual/api/keyboard-routines/">Keyboard Routines</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Matthew Dalrymple)</author>
		<pubDate>Sun, 04 Feb 2007 09:57:07 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>try looking at d_edit_proc, otherwise consider writing it yourself, is not that hard, also there is a small routine on the code gallery, look at it and go from there.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (vbovio)</author>
		<pubDate>Sun, 04 Feb 2007 09:57:10 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Yes hehe I was just going to post that.  I have a couple of threads made dealing with text input.</p><p>Here&#39;s the other one:  <a href="http://www.allegro.cc/forums/thread/589667">http://www.allegro.cc/forums/thread/589667</a>
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (julian_boolean)</author>
		<pubDate>Sun, 04 Feb 2007 09:59:42 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Ack, compiling error I can&#39;t figure out.</p><div class="source-code snippet"><div class="inner"><pre>        <a href="http://www.allegro.cc/manual/DIALOG" target="_blank"><span class="a">DIALOG</span></a> the_dialog<span class="k2">[</span><span class="k2">]</span> <span class="k3">=</span> 
        <span class="k2">{</span>
        <span class="k2">{</span> d_agup_edit_proc,     <span class="n">15</span>, <span class="n">75</span>, <span class="n">125</span>,  <span class="n">8</span>,  <span class="n">0</span>,  <span class="n">0</span>,  <span class="n">0</span>,  <span class="n">0</span>,  <span class="n">100</span>,   <span class="n">0</span>,  name,     NULL,  name <span class="k2">}</span>,
        <span class="k2">{</span> d_agup_push_proc,     <span class="n">90</span>, <span class="n">115</span>, <span class="n">100</span>, <span class="n">18</span>,  <span class="n">0</span>,  <span class="n">0</span>,  <span class="n">0</span>,  <span class="n">0</span>,       <span class="n">0</span>,   <span class="n">0</span>,  <span class="k2">(</span><span class="k1">void</span><span class="k3">*</span><span class="k2">)</span><span class="s">"Done"</span>,     <span class="n">0</span>, edit_high<span class="k2">(</span>pos, name, count<span class="k2">)</span> <span class="k2">}</span>,        
                 <span class="c">/* the next two elements don't draw anything */</span>
               <span class="k2">{</span> <a href="http://www.allegro.cc/manual/d_yield_proc" target="_blank"><span class="a">d_yield_proc</span></a>,        <span class="n">0</span>,   <span class="n">0</span>,    <span class="n">0</span>,    <span class="n">0</span>,   <span class="n">0</span>,  <span class="n">0</span>,    <span class="n">0</span>,      <span class="n">0</span>,       <span class="n">0</span>,   <span class="n">0</span>,    NULL,                   NULL, NULL  <span class="k2">}</span>,
               <span class="k2">{</span> NULL,                <span class="n">0</span>,   <span class="n">0</span>,    <span class="n">0</span>,    <span class="n">0</span>,   <span class="n">0</span>,  <span class="n">0</span>,    <span class="n">0</span>,      <span class="n">0</span>,       <span class="n">0</span>,   <span class="n">0</span>,    NULL,                   NULL, NULL  <span class="k2">}</span>
        <span class="k2">}</span><span class="k2">;</span>
</pre></div></div><p>
</p><div class="source-code"><div class="toolbar"></div><div class="inner"><table width="100%"><tbody><tr><td class="number">1</td><td><span class="k1">void</span> edit_high<span class="k2">(</span><span class="k1">long</span> pos, <span class="k1">char</span> name<span class="k2">[</span><span class="n">100</span><span class="k2">]</span>, <span class="k1">int</span> count<span class="k2">)</span> <span class="k2">{</span></td></tr><tr><td class="number">2</td><td>     <span class="k1">int</span> end_score<span class="k2">;</span></td></tr><tr><td class="number">3</td><td>     <span class="k1">int</span> end_lvl<span class="k2">;</span></td></tr><tr><td class="number">4</td><td>&#160;</td></tr><tr><td class="number">5</td><td>&#160;</td></tr><tr><td class="number">6</td><td>     FILE <span class="k3">*</span> file<span class="k2">;</span></td></tr><tr><td class="number">7</td><td>     file <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_337.html" target="_blank">fopen</a><span class="k2">(</span><span class="s">"High.txt"</span>,<span class="s">"r+"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">8</td><td>&#160;</td></tr><tr><td class="number">9</td><td>     </td></tr><tr><td class="number">10</td><td>&#160;</td></tr><tr><td class="number">11</td><td>     <a href="http://www.delorie.com/djgpp/doc/libc/libc_354.html" target="_blank">fseek</a><span class="k2">(</span>file, pos, SEEK_SET<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">12</td><td>     <a href="http://www.delorie.com/djgpp/doc/libc/libc_345.html" target="_blank">fprintf</a><span class="k2">(</span>file, <span class="s">"NEW\n"</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">13</td><td>     <a href="http://www.delorie.com/djgpp/doc/libc/libc_345.html" target="_blank">fprintf</a><span class="k2">(</span>file,<span class="s">"%d\n"</span>, score<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">14</td><td>     <a href="http://www.delorie.com/djgpp/doc/libc/libc_345.html" target="_blank">fprintf</a><span class="k2">(</span>file,<span class="s">"%d\n"</span>, lvl_nr<span class="k3">+</span><span class="n">1</span><span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">15</td><td>     <span class="k1">if</span> <span class="k2">(</span>count <span class="k3">&lt;</span> <span class="n">10</span><span class="k2">)</span> <span class="k2">{</span></td></tr><tr><td class="number">16</td><td>        <a href="http://www.delorie.com/djgpp/doc/libc/libc_345.html" target="_blank">fprintf</a><span class="k2">(</span>file, <span class="s">"%s\n"</span>, name<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">17</td><td>        <a href="http://www.delorie.com/djgpp/doc/libc/libc_345.html" target="_blank">fprintf</a><span class="k2">(</span>file,<span class="s">"%d\n"</span>, end_score<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">18</td><td>        <a href="http://www.delorie.com/djgpp/doc/libc/libc_345.html" target="_blank">fprintf</a><span class="k2">(</span>file,<span class="s">"%d\n"</span>, end_lvl<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">19</td><td>     <span class="k2">}</span></td></tr><tr><td class="number">20</td><td>&#160;</td></tr><tr><td class="number">21</td><td>&#160;</td></tr><tr><td class="number">22</td><td>     <span class="k1">for</span> <span class="k2">(</span><span class="k1">int</span> i <span class="k3">=</span> <span class="k2">(</span>count<span class="k3">+</span><span class="n">1</span><span class="k2">)</span><span class="k2">;</span> i <span class="k3">&lt;</span><span class="k3">=</span> <span class="n">10</span><span class="k2">;</span> i<span class="k3">+</span><span class="k3">+</span><span class="k2">)</span> <span class="k2">{</span></td></tr><tr><td class="number">23</td><td>         cout <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"I: "</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> i <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"\n"</span><span class="k2">;</span></td></tr><tr><td class="number">24</td><td>         cout <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"Count: "</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> count <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"\n"</span><span class="k2">;</span></td></tr><tr><td class="number">25</td><td>         pos <span class="k3">=</span> <a href="http://www.delorie.com/djgpp/doc/libc/libc_366.html" target="_blank">ftell</a><span class="k2">(</span>file<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">26</td><td>         <a href="http://www.delorie.com/djgpp/doc/libc/libc_354.html" target="_blank">fseek</a><span class="k2">(</span>file, pos-1, SEEK_SET<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">27</td><td>         cout <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"POS before: "</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> pos <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"\n"</span><span class="k2">;</span></td></tr><tr><td class="number">28</td><td>         <a href="http://www.delorie.com/djgpp/doc/libc/libc_353.html" target="_blank">fscanf</a><span class="k2">(</span>file, <span class="s">"%s"</span>, name<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">29</td><td>         <a href="http://www.delorie.com/djgpp/doc/libc/libc_353.html" target="_blank">fscanf</a><span class="k2">(</span>file, <span class="s">"%d"</span>, <span class="k3">&amp;</span>end_score<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">30</td><td>         <a href="http://www.delorie.com/djgpp/doc/libc/libc_353.html" target="_blank">fscanf</a><span class="k2">(</span>file, <span class="s">"%d"</span>, <span class="k3">&amp;</span>end_lvl<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">31</td><td>         <a href="http://www.delorie.com/djgpp/doc/libc/libc_354.html" target="_blank">fseek</a><span class="k2">(</span>file, pos, SEEK_SET<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">32</td><td>         <a href="http://www.delorie.com/djgpp/doc/libc/libc_345.html" target="_blank">fprintf</a><span class="k2">(</span>file, <span class="s">"%s\n"</span>, name<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">33</td><td>         <a href="http://www.delorie.com/djgpp/doc/libc/libc_345.html" target="_blank">fprintf</a><span class="k2">(</span>file,<span class="s">"%d\n"</span>, end_score<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">34</td><td>         <a href="http://www.delorie.com/djgpp/doc/libc/libc_345.html" target="_blank">fprintf</a><span class="k2">(</span>file,<span class="s">"%d\n"</span>, end_lvl<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">35</td><td>         cout <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"POS after: "</span> <span class="k3">&lt;</span><span class="k3">&lt;</span> pos <span class="k3">&lt;</span><span class="k3">&lt;</span> <span class="s">"\n"</span><span class="k2">;</span></td></tr><tr><td class="number">36</td><td>     <span class="k2">}</span></td></tr><tr><td class="number">37</td><td>    <a href="http://www.delorie.com/djgpp/doc/libc/libc_308.html" target="_blank">fclose</a><span class="k2">(</span>file<span class="k2">)</span><span class="k2">;</span></td></tr><tr><td class="number">38</td><td><span class="k2">}</span></td></tr></tbody></table></div></div><p>

That gives this error: void value not ignored as it ought to be
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Raf Vermeulen)</author>
		<pubDate>Sun, 04 Feb 2007 21:25:51 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>That means that you assigned the result of a statement that evaluates to void (typically a function with return type void) to something, or passed it to a function as a parameter.<br />The compiler give you a source code line number. Check the line in question and see if you don&#39;t do anything like this:
</p><div class="source-code snippet"><div class="inner"><pre><span class="k1">void</span> my_func<span class="k2">(</span><span class="k2">)</span> <span class="k2">{</span>
  <span class="c">// do some stuff here</span>
<span class="k2">}</span>

<span class="k1">int</span> main<span class="k2">(</span><span class="k2">)</span> <span class="k2">{</span>
  <span class="k1">int</span> a <span class="k3">=</span> my_func<span class="k2">(</span><span class="k2">)</span><span class="k2">;</span> <span class="c">// &lt;- This line will trigger an error.</span>
  <span class="k1">return</span> <span class="n">0</span><span class="k2">;</span>
<span class="k2">}</span>
</pre></div></div><p>

--- EDIT ---<br />Oh, I see it. You assign the return value of edit_high to a field in the DIALOG structure. That can&#39;t be what you want.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Sun, 04 Feb 2007 22:18:06 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The line number it gives, is the last line of the upper code. If I comment out the d_agup_push_proc line, it works fine, so there must be something with the call to the function edit_high in there, but it all seems in order to me.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Raf Vermeulen)</author>
		<pubDate>Sun, 04 Feb 2007 22:20:12 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>It is not, I already explained.<br />The line in question calls edit_high(), then stores the result (the return value) in the dialog array. Since edit_high() returns nothing (void), there is nothing to store in the array, and the value put into the struct is undefined. You are not doing it right. <br />My guess is that you want the dialog item to trigger the edit_high function; in that case, you need to do one of the following things:<br />a) use a dialog item that can trigger a function, and pass edit_high itself to it, that is, just the function name, without the brackets or any arguments (which will be interpreted as a function pointer). This is only possible if the dialog item in fact supports this, and if the argument structure and return type are exactly what the dialog item expects.<br />b) make the dialog item exit the dialog, and if this item is the one triggering an end-of-dialog, execute edit_high() manually and re-run the dialog afterwards.<br />c) use a custom dialog procedure that checks if the button has been pressed; if so, it executes edit_high(), then resumes executing the dialog.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Sun, 04 Feb 2007 22:28:56 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>The dialog is initted at load-time, and as you have it, to fill in the dialog it has to run your function to get its return value. However, your function returns a void, and the place your&#39;re putting it wants a void*.</p><p>What you want to do is pass a function pointer, not call the function. Do that by omitting the parameters and (). The dialog code will run your function, not you. And as a result, it can only take the parameters the dialog code gives it, not the ones you want it to have. Same with its return value.
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Kitty Cat)</author>
		<pubDate>Sun, 04 Feb 2007 22:29:39 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Good explanation.<br />One more thing: If you compile as C++ (as opposed to C), you need to manually cast your function pointer to void* by putting (void*) in front of it (including the brackets).
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Tobias Dammers)</author>
		<pubDate>Sun, 04 Feb 2007 22:34:27 +0000</pubDate>
	</item>
	<item>
		<description><![CDATA[<div class="mockup v2"><p>Sweet, it compiles now:D Can&#39;t actually click it or edit the text in the textfield, but it&#39;s progress:D
</p></div>]]>
		</description>
		<author>no-reply@allegro.cc (Raf Vermeulen)</author>
		<pubDate>Sun, 04 Feb 2007 22:42:40 +0000</pubDate>
	</item>
</rss>
