[erlang-questions] variable unbound

Bengt Kleberg <>
Thu Apr 2 13:20:36 CEST 2009


Greetings,

The compiler finds that you have not used the File variable. Instead you
open the string constant "File".
Neither do you use the S variable from the case statement (with
file:open/2).

The unbound S is the one in io:format/2. It does not have a value.


bengt

On Thu, 2009-04-02 at 12:03 +0200, Gamoto wrote:
> What is wrong in this function ? I receive the following error: variable 'S' is unbound !
> I also receive two warnings: File is unused, S is unused.
> This process can receive two messages: one file to open and one message to write
> 
> Pid ! {open,"filetoopen.txt"}
> 
> Pid ! {data, Message}
> 
> log_message()->
>     receive
> 		{open,File} -> case file:open("File", [append]) of
> 							{ok,S} ->  log_message();
> 		                    {error,Reason} -> io:format( "~s~n",[Reason])
> 		       	            end;
> 		{data,Data} ->  io:format(S,"~s~n",[Data]),
> 	    					  log_message()
>    end.
> 
> _______________________________________________
> erlang-questions mailing list
> 
> http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list