program InfoViewer;
{ written mid december 1990 to date by woody }
{ dos version }
uses
  DOS, CRT, Graph;

{$I headers.inc}

const
  Version  = 'dos 0.85b';

var {globals}
  space     : TheVoid;
  BBSname   : string;
  g         : text;
  BaseChanged,
  quit      : boolean;
  distances : distanceArray;

{$I QUEUE.INC }
{$I status.inc }
{$I misc.inc }
{$I distance.inc }
{$I viewdos.inc }
{$I textdisp.inc }
{$I portdisp.inc }
{$I notestuf.inc }
{$I pathstuf.inc }
{$I teleport.inc }
{$I GSDATA.INC }

procedure menu;
begin
  writeln('Choose one of ');
  writeln('<A>dd note');
  writeln('Closest place to buy <F>ighters, shields, and holds');
  writeln('Note <I>nformation');
  writeln('<L>ength of path between two sectors');
  writeln('<N>earest port');
  writeln('<P>aired ports');
  writeln('<Q>uit');
  writeln('Nearest <S>ectors');
  writeln('<T>ranswarp menu');
  writeln('Nearest <U>nexplored sectors');
  writeln('<V>iew space in graphic format');
  writeln('e<X>cise note (delete it)');
  writeln;
end; {menu}

function choice : char;
var
  ch : char;
begin
  write('(', BBSName, ') [A, F, I, L, N, P, Q, S, T, U, V, X] Your choice?  ');
  readln( ch );
  choice := upcase( ch );
end;

begin
  writeln('Tradewars Data Base Viewer: version ', version);
  writeln( author );
  writeln( source );
  writeln;
  Quit := false;
  BaseChanged := false;
  InitSpace( Space );
  if paramCount > 0 then
    BBSName := ParamStr( 1 )
  else
    BBSName := '';
  GetData( Space, BBSName );
  menu;
  repeat
    case choice of
    'A' : AddNote( BaseChanged );
    'F' : NearestFighters;
    'I' : NearestStuff( NoteOnly );
    'L' : PathLength;
    'N' : NearestStuff( PortOnly );
    'P' : pairPort;
    'Q' : quit := true;
    'S' : NearestStuff( any );
    'T' : TransWarpMenu( BaseChanged );
    'U' : NearestStuff( UnExpOnly );
    'V' : view;
    'X' : RemoveNote( BaseChanged );
    else
      menu;
    end; {case}
  until quit;
  if BaseChanged then
    begin
      assign( g, GetNewFileName('File name for new data base? ',
                                  bbsname+'.dat') );
      rewrite( g );
      saveData( g, space );
    end;
end.