Hi,<br><br>You should export loop function, too.<br><br><span style="font-size:10.0pt;font-family:"Courier New";color:blue">-export</span><span style="font-size:10.0pt;font-family:"Courier New"">([start/1, loop/1]).</span><br>

<br>Best,<br><br>Zsolt<br><br><div class="gmail_quote">On Tue, Apr 16, 2013 at 2:52 PM, John Williston <span dir="ltr"><<a href="mailto:jwilliston@drsys.com" target="_blank">jwilliston@drsys.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div link="blue" vlink="purple" lang="EN-US"><div><p class="MsoNormal">Good morning,<u></u><u></u></p><p class="MsoNormal">
<u></u>†<u></u></p><p class="MsoNormal">Iím learning Erlang using the <i>Programming Erlang</i> (2d ed) text from Pragmatic Bookshelf. Chapter two, ďA Whirlwind Tour of ErlangĒ includes a file server sample thatís failing to work as the book suggests, and Iím afraid Iím not getting anywhere figuring it out. First, hereís the server code:<u></u><u></u></p>
<p class="MsoNormal"><u></u>†<u></u></p><p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">-module</span><span style="font-size:10.0pt;font-family:"Courier New"">(afile_server).<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:10.0pt;font-family:"Courier New";color:blue">-export</span><span style="font-size:10.0pt;font-family:"Courier New"">([start/1]).<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:10.0pt;font-family:"Courier New""><u></u>†<u></u></span></p><p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:10.0pt;font-family:"Courier New"">start(Dir) -> </span><span style="font-size:10.0pt;font-family:"Courier New";color:#2996b5">spawn</span><span style="font-size:10.0pt;font-family:"Courier New"">(afile_server, loop, [Dir]).<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:10.0pt;font-family:"Courier New""><u></u>†<u></u></span></p><p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:10.0pt;font-family:"Courier New"">loop(Dir) -><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:10.0pt;font-family:"Courier New"">††† </span><span style="font-size:10.0pt;font-family:"Courier New";color:blue">receive</span><span style="font-size:10.0pt;font-family:"Courier New""><u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:10.0pt;font-family:"Courier New"">††††††† {Client, list_dir} -><u></u><u></u></span></p><p class="MsoNormal" style="margin-left:.5in;background:white">
<span style="font-size:10.0pt;font-family:"Courier New"">††††††††††† Client ! {</span><span style="font-size:10.0pt;font-family:"Courier New";color:#2996b5">self</span><span style="font-size:10.0pt;font-family:"Courier New"">(), file:list_dir(Dir)};<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:10.0pt;font-family:"Courier New"">††††††† {Client, {get_file, File}} -><u></u><u></u></span></p><p class="MsoNormal" style="margin-left:.5in;background:white">
<span style="font-size:10.0pt;font-family:"Courier New"">††††††††††† Full = filename:join(Dir, File),<u></u><u></u></span></p><p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:10.0pt;font-family:"Courier New"">††††††††††† Client ! {</span><span style="font-size:10.0pt;font-family:"Courier New";color:#2996b5">self</span><span style="font-size:10.0pt;font-family:"Courier New"">(), file:read_file(Full)}<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:10.0pt;font-family:"Courier New"">††† </span><span style="font-size:10.0pt;font-family:"Courier New";color:blue">end</span><span style="font-size:10.0pt;font-family:"Courier New"">,<u></u><u></u></span></p>
<p class="MsoNormal" style="margin-left:.5in;background:white"><span style="font-size:10.0pt;font-family:"Courier New"">††† loop(Dir).<u></u><u></u></span></p><p class="MsoNormal" style="background:white"><span style="font-size:10.0pt;font-family:"Courier New""><u></u>†<u></u></span></p>
<p class="MsoNormal">That compiles (albeit with a warning saying ďWarning: function loop/1 is unusedĒ) but when I try to execute it from within the shell I get an error. For sake of reference the shell commands Iím issuing are:<u></u><u></u></p>
<p class="MsoNormal"><u></u>†<u></u></p><p class="MsoNormal" style="margin-left:.5in">Eshell V5.10.1† (abort with ^G)<u></u><u></u></p><p class="MsoNormal" style="margin-left:.5in">1> c(afile_server).<u></u><u></u></p>
<p class="MsoNormal" style="margin-left:.5in">afile_server.erl:7: Warning: function loop/1 is unused<u></u><u></u></p><p class="MsoNormal" style="margin-left:.5in">{ok,afile_server}<u></u><u></u></p><p class="MsoNormal" style="margin-left:.5in">
2> FileServer = afile_server:start(".").<u></u><u></u></p><p class="MsoNormal" style="margin-left:.5in"><0.39.0><u></u><u></u></p><p class="MsoNormal" style="margin-left:.5in">3><u></u><u></u></p><p class="MsoNormal" style="margin-left:.5in">
=ERROR REPORT==== 10-Apr-2013::10:31:17 ===<u></u><u></u></p><p class="MsoNormal" style="margin-left:.5in">Error in process <0.39.0> with exit value: {undef,[{afile_server,loop,["."],[]}]}<u></u><u></u></p>
<p class="MsoNormal"><u></u>†<u></u></p><p class="MsoNormal">Can anyone suggest what might be wrong? Iím running under Windows 7 Professional x64 for sake of reference. Thanks in advance!<span class="HOEnZb"><font color="#888888"><u></u><u></u></font></span></p>
<span class="HOEnZb"><font color="#888888"><p class="MsoNormal"><u></u>†<u></u></p><p class="MsoNormal">John<u></u><u></u></p></font></span></div></div><br>_______________________________________________<br>
erlang-questions mailing list<br>
<a href="mailto:erlang-questions@erlang.org">erlang-questions@erlang.org</a><br>
<a href="http://erlang.org/mailman/listinfo/erlang-questions" target="_blank">http://erlang.org/mailman/listinfo/erlang-questions</a><br>
<br></blockquote></div><br>