Program WyrmComm;

{***************************************************************************}

{* Parts from p. 585 Complete Turbo Pascal 3rd ed.

{***************************************************************************}



uses

  Comm,

  Crt,

  Data,

  Dos,

  Glob,

  Scrn;



var

  Baud: integer;

  KeyChar: char;

  Quit: boolean;



Procedure BaudSwitch;

{***************************************************************************}

var

  BaudStr: string;

begin

  write('BAUD [1200]:  ');

  readln(BaudStr);

  if BaudStr = '' then

    Baud := 1200

  else

    Baud := IntStr(BaudStr);

  Comm.SetupSerialPort(Baud);

end;



Procedure ShowHelp;

{***************************************************************************}

begin

  writeln('Control-B --------- Change the Baud');

  writeln('Control-D --------- Dial the Wyrm BBS at 1-805-258-1714');

  writeln('Control-X --------- Quit');

  writeln('Control-Z --------- Clear Screen');

end;



{***************************************************************************}

{***************************************************************************}

{***************************************************************************}

begin

  DirectVideo := true;

  Baud := 1200;

  Comm.SetupSerialPort(Baud);

  ClrScr;

  Scrn.ReverseVideo;

  Scrn.Center('WyrmComm by David Croft.  Press F1 for help.');

  Crt.NormVideo;

  Window(1,2,80,25);

  Quit := false;

  repeat

    if InStat then

      write(InChar);

    if KeyPressed then

      begin

        KeyChar := ReadKey;

        if KeyChar = Chr(0) then

          begin

            KeyChar := ReadKey;

            case Ord(KeyChar) of

              59:  ShowHelp;

            end; {case}

          end

        else

          case KeyChar of

            Cntrl_B:  BaudSwitch;

            Cntrl_D:  Comm.OutStr('ATDT 1-805-258-1714');

            Cntrl_X:  Quit := true;

            Cntrl_Z:  ClrScr;

            else

              Comm.OutChar(KeyChar);

          end; {case}

      end;

  until Quit;

end.



