anchor.diff:  %%       Result = ok | {error, Reason}
   %%       Reason = ext_posix() | terminated | system_limit
   %%--------------------------------------------------------------------
  -generate_source (ProtoFile) when is_list (ProtoFile) ->
  +generate_source(ProtoFile) ->
  +    generate_source(ProtoFile,[]).
  +
  +%%--------------------------------------------------------------------
  +%% @doc Generats a source .erl file and header file .hrl
  +%%      Consider option properties: output_include_dir, 
  +%%                                  output_src_dir 
  +%% @spec scan_file(ProtoFile,Options) -> Result
  +%%       ProtoFile = string()
  +%%       Options = proplists()
  +%%       Result = ok | {error, Reason}
  +%%       Reason = ext_posix() | terminated | system_limit
  +%%--------------------------------------------------------------------
  +generate_source(ProtoFile,Options) when is_list (ProtoFile) ->
       Basename = filename:basename(ProtoFile, ".proto") ++ "_pb",
       {ok,Parsed} = parse(ProtoFile),
       {{msg,UntypedMessages},{enum,Enums}} = collect_full_messages(Parsed),
       Messages = resolve_types(UntypedMessages,Enums),
  -    output_source (Basename, Messages, Enums).
  -
  -output(Basename, Messages, Enums) ->
  -    ok = write_header_include_file(Basename, Messages),
  -    BeamFile = filename:dirname(code:which(?MODULE)) ++ "/pokemon_pb.beam",
  -    {ok,{_,[{abstract_code,{_,Forms}}]}} = beam_lib:chunks(BeamFile, [abstract_code]),
  +    output_source (Basename, Messages, Enums, Options).
  +
  +%% @hidden
  +output(Basename, Messages, Enums, Options) ->
  +    case proplists:get_value(output_include_dir,Options) of
  +	undefined ->
  +	    HeaderFile = Basename ++ ".hrl";
  +	HeaderPath ->
  +	    HeaderFile = filename:join(HeaderPath,Basename) ++ ".hrl"
  +    end,
  +    error_logger:info_msg("Writing header file to ~p~n",[HeaderFile]),
  +    ok = write_header_include_file(HeaderFile, Messages),
  +    PokemonBeamFile = filename:dirname(code:which(?MODULE)) ++ "/pokemon_pb.beam",
  +    {ok,{_,[{abstract_code,{_,Forms}}]}} = beam_lib:chunks(PokemonBeamFile, [abstract_code]),
       Forms1 = filter_forms(Messages, Enums, Forms, Basename, []),
       {ok, _, Bytes, _Warnings} = compile:forms(Forms1, [return]),
  -    file:write_file(Basename ++ ".beam", Bytes).
  -
  -%% @hidden
  -output_source (Basename, Messages, Enums) ->
  -    ok = write_header_include_file(Basename, Messages),
  -    BeamFile = filename:dirname(code:which(?MODULE)) ++ "/pokemon_pb.beam",
  -    {ok,{_,[{abstract_code,{_,Forms}}]}} = beam_lib:chunks(BeamFile, [abstract_code]),
  +    case proplists:get_value(output_ebin_dir,Options) of
  +	undefined ->
  +	    BeamFile = Basename ++ ".beam";
  +	BeamPath ->
  +	    BeamFile = filename:join(BeamPath,Basename) ++ ".beam"
  +    end,
  +    error_logger:info_msg("Writing beam file to ~p~n",[BeamFile]),
  +    file:write_file(BeamFile, Bytes).
  +
  +%% @hidden
  +output_source (Basename, Messages, Enums, Options) ->
  +    case proplists:get_value(output_include_dir,Options) of
  +	undefined ->
  +	    HeaderFile = Basename ++ ".hrl";
  +	HeaderPath ->
  +	    HeaderFile = filename:join(HeaderPath,Basename) ++ ".hrl"
  +    end,
  +    error_logger:info_msg("Writing header file to ~p~n",[HeaderFile]),
  +    ok = write_header_include_file(HeaderFile, Messages),
  +    PokemonBeamFile = filename:dirname(code:which(?MODULE)) ++ "/pokemon_pb.beam",
  +    {ok,{_,[{abstract_code,{_,Forms}}]}} = beam_lib:chunks(PokemonBeamFile, [abstract_code]),
       Forms1 = filter_forms(Messages, Enums, Forms, Basename, []),
  -    file:write_file(Basename ++ ".erl", erl_prettypr:format(erl_syntax:form_list (Forms1))).
  +    case proplists:get_value(output_src_dir,Options) of
  +	undefined ->
  +	    SrcFile = Basename ++ ".erl";
  +	SrcPath ->
  +	    SrcFile = filename:join(SrcPath,Basename) ++ ".erl"
  +    end,
  +    error_logger:info_msg("Writing src file to ~p~n",[SrcFile]),
  +    file:write_file(SrcFile, erl_prettypr:format(erl_syntax:form_list (Forms1))).
   
   %% @hidden
   parse(FileName) ->
  
positive.code: %%       Result = ok | {error, Reason}
  %%       Reason = ext_posix() | terminated | system_limit
  %%--------------------------------------------------------------------
  scan_file(ProtoFile) when is_list(ProtoFile) ->
      Basename = filename:basename(ProtoFile, ".proto") ++ "_pb",
      {ok,Parsed} = parse(ProtoFile),
      {{msg,UntypedMessages},{enum,Enums}} = collect_full_messages(Parsed),
      Messages = resolve_types(UntypedMessages,Enums),
      output(Basename, Messages, Enums).
  
  %%--------------------------------------------------------------------
  %% @doc Generats a source .erl file and header file .hrl
  
negative.code: 
  %% @hidden
  write_header_include_file(Basename, Messages) ->
      {ok, FileRef} = file:open(Basename, [write]),
      [begin
  	 OutFields = [string:to_lower(A) || {_, _, _, A, _, _} <- lists:keysort(1, Fields)],
  	 if
  