<div class="gmail_quote">2009/4/2 Gamoto <span dir="ltr"><gamoto@bluewin.ch></span><br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
What is wrong in this function ? I receive the following error: variable 'S' is unbound !<br>
I also receive two warnings: File is unused, S is unused.<br>
This process can receive two messages: one file to open and one message to write<br>
<br>
Pid ! {open,"filetoopen.txt"}<br>
<br>
Pid ! {data, Message}<br>
<br>
log_message()-><br>
receive<br>
{open,File} -> case file:open("File", [append]) of<br>
{ok,S} -> log_message();<br>
{error,Reason} -> io:format( "~s~n",[Reason])<br>
end;<br>
{data,Data} -> io:format(S,"~s~n",[Data]),<br>
log_message()<br>
end.</blockquote><div><br>- The variable File is defined in the message {file,File} you recieve but is never used, you open the file "File".<br><br>- The variable S is defined when you receive the {open,File} message, but you wish to use it when you receive the {data,Data} message where it is not defined.<br>
<br>Robert<br><br></div></div>