{ Part one will parse a log file, and store explored sectors; then
create a text file that you can feed to the computer that will give you
a map of the universe.  Part two will take a log file generated from
feeding the first to the computer, and create a data file that can
be fed into something else.

Well, this has been expanded a bit since the first note.  It now does
a variety of conversion tasks, from fighter clouds to major space lane stuff.
But that is always the problem with programs -- they always outstrip the
documentation, eh?  Program begun Dec 1990 by woody.
}
program converter;
uses
  dos, crt;

{$I headers.inc}

const
  Version  = ' dos 0.85b';

var
  ext,
  mss       : string;
  othername,
  BBSName   : string;
  n         : integer;
  f, g      : text;
  space     : TheVoid;

{$I QUEUE.INC }
{$I status.inc }
{$I misc.inc }
{$I PortStat.inc }
{$I gsdata.inc }
{$I part13.inc}
{$I part2.inc}
{$I part4.inc}
{$I part5.inc}
{$I part6.inc}
{$I editbase.inc}

begin {main}
  writeln('Tradewars Data Base generator: version', Version);
  writeln( author );
  writeln( source );
  writeln;
  InitSpace( Space );
  if paramCount > 0 then
    BBSName := ParamStr( 1 )
  else
    BBSName := '';
  GetData( space, BBSName );
  repeat
    repeat
      writeln('Choices:');
      writeln('  (0)  Let me out of here!');
      writeln('  (1)  Read "Explored/Unexplored Sectors" list for newly scanned sectors');
      writeln('  (2)  Read log files for inter-warp and port information');
      writeln('  (3)  Read "Fighter Display" list for fighter clouds');
      writeln('  (4)  Generate upload file for determining Major Space Lanes');
      writeln('  (5)  Read "Major Space Lanes" downloaded file into database');
      writeln('  (6)  Add some other explorer''s data into database');
      writeln('  (7)  Perform editing on data base');
      writeln;
      write('(', BBSname, ')  Your choice?  (0, 1, 2, 3, 4, 5, 6, or 7) ');
      readln( n );
    until n in [0..7];
    if n = 0 then halt;
    if not (n in [4,7]) then
      begin
        case n of
          1 : begin mss := '"Explored/Unexplored Sectors"'; ext := 'exp'; end;
          2 : begin mss := 'log'; ext := 'log'; end;
          3 : begin mss := '"Deployed Fighter Scan"'; ext := 'ftr'; end;
          4 : mss := 'This case shouldn''t happen.';
          5 : begin mss := '"Major Space Lanes"'; ext := 'msl'; end;
          6 : begin mss :='other database'; ext:= 'unk'; end;
          7 : mss := 'This shouldn''t happen either.';
        end; {case}
        othername := GetOldFileName( 'Name of ' + mss + ' file?  ',
                                     bbsname + '.' + ext );
        if n <> 6 then
          begin
            assign( f, othername);
            reset( f );
          end; {if}
      end; {if}
    assign( g, GetNewFileName('Name of file to generate? ', abort) );
    rewrite( g );
    case n of
      1 : partOneThree;
      2 : partII( space);
      3 : partIV( space );
      4 : partV;
      5 : partVI( space );
      6 : begin GetData( space, othername ); SaveData( g, space ); end;
      7 : begin EditMenu; SaveData( g, space ); end;
    end; {case}
    if n in [1, 2, 3, 5] then
      close( f );
    if n in [1..5] then
      close( g );            { SaveData does its own file closing }
  until n = 0;
end.