anchor.diff:  %%  Read a included file. Try current dir first then the IncDir list
   %%===============================================================
   
  -read_inc_file(FileName, IncDir) ->
  -    case catch file:read_file(FileName) of
  -	{ok, Bin} ->
  -	    FileList = binary_to_list(Bin),
  -	    {ok, FileList, FileName};
  +read_inc_file(FileName, IncDir, Mio) ->
  +    case find_inc_file(FileName, IncDir) of
  +        {ok, AbsFile} ->
  +            %% is included before?
  +            case lists:member(FileName, Mio#mio.included) of
  +                false ->
  +                    case catch file:read_file(AbsFile) of
  +                        {ok, Bin} ->
  +                            FileList = binary_to_list(Bin),
  +                            {ok, AbsFile, FileList};
  +                        {error, Text} ->
  +                            {error, Text}
  +                    end;
  +                true ->
  +                    skip
  +            end;
  +        {error, Text} ->
  +            {error, Text}
  +    end.
  +
  +find_inc_file(FileName, IncDir) ->
  +    case catch file:read_file_info(FileName) of
  +	{ok, _} ->
  +	    {ok, FileName};
   	{error, _} ->
  -	    read_inc_file2(FileName, IncDir) 
  +	    find_inc_file2(FileName, IncDir)
       end.
   
  -read_inc_file2(_FileName, []) ->
  +find_inc_file2(_FileName, []) ->
       {error, "No such file or directory"};
  -read_inc_file2(FileName, [D|Rem]) ->
  +find_inc_file2(FileName, [D|Rem]) ->
       Dir = case lists:last(D) of
   	      $/ ->
   		  D;
  
positive.code:     end;
  
  
  expand([{var, "__LINE__"}|Rem], Out, SelfRef, Defs, IncFile, IncDir, IfCou, Err, War, L, FN) ->
      LL = io_lib:format("~p",[L]),
      expand(Rem, [LL | Out], SelfRef, Defs, IncFile, IncDir, IfCou, Err, War, L, FN);
  
  expand([{var, "__FILE__"}|Rem], Out, SelfRef, Defs, IncFile, IncDir, IfCou, Err, War, L, FN) ->
      expand(Rem, [$",FN,$" | Out], SelfRef, Defs, IncFile, IncDir, IfCou, Err, War, L, FN);
  
  expand([{var, "__DATE__"}|Rem], Out, SelfRef, Defs, IncFile, IncDir, IfCou, Err, War, L, FN) ->
      {{Y,M,D},{_H,_Mi,_S}} = calendar:universal_time(),
      Date = io_lib:format("\"~s ~p ~p\"",[month(M),D,Y]),
      expand(Rem, [Date | Out], SelfRef, Defs, IncFile, IncDir, IfCou, Err, War, L, FN);
  
  expand([{var, "__TIME__"}|Rem], Out, SelfRef, Defs, IncFile, IncDir, IfCou, Err, War, L, FN) ->
      {{_Y,_M,_D},{H,Mi,S}} = calendar:universal_time(),
      HS = if H < 10 -> "0"++integer_to_list(H);
  	    true -> integer_to_list(H)
  
negative.code:        true -> integer_to_list(S)
      end,
      Time = io_lib:format("\"~s:~s:~s\"",[HS,MiS,SS]),
      expand(Rem, [Time | Out], SelfRef, Defs, IncFile, IncDir, update_mio(Mio), IfCou, Err, War, L, FN);
  
  expand([{var, "__INCLUDE_LEVEL__"}|Rem], Out, SelfRef, Defs, IncFile, IncDir, Mio, IfCou, Err, War, L, FN) ->
      IL = io_lib:format("~p",[length(IncFile)-1]),
      expand(Rem, [IL | Out], SelfRef, Defs, IncFile, IncDir, update_mio(Mio), IfCou, Err, War, L, FN);
  
  expand([{var, "__BASE_FILE__"}|Rem], Out, SelfRef, Defs, IncFile, IncDir, Mio, IfCou, Err, War, L, FN) ->
      [BF|_T] = lists:reverse(IncFile),
      expand(Rem, [$",BF,$" | Out], SelfRef, Defs, IncFile, IncDir, update_mio(Mio), IfCou, Err, War, L, FN);
  
  expand([{var, Var} | Rem], Out, SelfRef, Defs, IncFile, IncDir, Mio, IfCou, Err, War, L, FN) ->
      {Out2, Err2, War2, Rem2, SelfRef2} = 
  	source_line(Var, Rem, SelfRef, Defs, Err, War, L, FN),
      expand(Rem2, [Out2 | Out], SelfRef2, Defs, IncFile, IncDir, update_mio(Mio), IfCou, Err2, War2, L, FN);
  
  expand([{char, Char} | Rem], Out, SelfRef, Defs, IncFile, IncDir, Mio, IfCou, Err, War, L, FN) ->
      expand(Rem, [Char | Out], SelfRef, Defs, IncFile, IncDir, update_mio(Mio), IfCou, Err, War, L, FN);
  
  expand([{number, Number} | Rem], Out, SelfRef, Defs, IncFile, IncDir, Mio, IfCou, Err, War, L, FN) ->
      expand(Rem, [Number | Out], SelfRef, Defs, IncFile, IncDir, update_mio(Mio), IfCou, Err, War, L, FN);
  
  expand([{expanded, Str} | Rem], Out, SelfRef, Defs, IncFile, IncDir, Mio, IfCou, Err, War, L, FN) ->
      expand(Rem, [Str | Out], SelfRef, Defs, IncFile, IncDir, update_mio(Mio), IfCou, Err, War, L, FN);
  
  expand([{self_ref, Str} | Rem], Out, SelfRef, Defs, IncFile, IncDir, Mio, IfCou, Err, War, L, FN) ->
      SelfRef2 = lists:delete(Str,SelfRef),
      expand(Rem, Out, SelfRef2, Defs, IncFile, IncDir, update_mio(Mio), IfCou, Err, War, L, FN);
  
  expand([{string, Str} | Rem], Out, SelfRef, Defs, IncFile, IncDir, Mio, IfCou, Err, War, L, FN) ->
      expand(Rem, [$", Str, $" | Out], SelfRef, Defs, IncFile, IncDir, update_mio(Mio), IfCou, Err, War, L, FN);
  
  expand([{string_part, Str} | Rem], Out, SelfRef, Defs, IncFile, IncDir, Mio, IfCou, Err, War, L, FN) ->
      {Str2, Rem2, Nl} = expand_string_part([$"|Str], Rem),
      expand(Rem2, [Str2| Out], SelfRef, Defs, IncFile, IncDir, update_mio(Mio), IfCou, Err, War, L+Nl, FN).
  
  
  
  