Unit CommSoft; {the direct link version}



Interface

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

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

Uses

  Crt,

  LctSupp,

  LctKrnl;



Const

  Nul:  string = '';



Procedure IntroComm;

Procedure ClosePortComm;

Procedure OutComm(Message: string);

Procedure InComm(var IncomingMessage: string);



Implementation

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

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

var

  DumBool: boolean;

  DumInt: integer;



Procedure IntroComm;

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

var

  option: char;

begin

  TextBackground(Black);

  TextColor(Red);

  clrscr;

  writeln('COMMSOFT.TPU -- a Turbo Pascal Unit.');

  writeln;

  write('This portion of the program was written by C1C David W. Croft, ');

    writeln('Class of ''90.');

  writeln('It handles the direct computer to computer communications.');

  writeln('It was created using Turbo Pascal 5.5 and LiteComm.');

  writeln('It requires the LiteComm files LctSupp.TPU and LctKrnl.TPU.');

  writeln;

  writeln('Please hit ENTER or Q to quit.');

  option := readkey;

  if upcase(option) = 'Q' then

    halt;

  TextBackground(Blue);

  TextColor(White);

end;



Procedure ClosePortComm;

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

begin

  CommClose(2, true);

end;



Procedure OutComm(Message: string);

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

type

  StrBuff = array[1..255] of char;

var

  MessageBuff: StrBuff;

  LenMessageBuff: integer;

  alpha: integer;

begin

  LenMessageBuff := length(Message);

  for alpha := 1 to LenMessageBuff do

    MessageBuff[alpha] := Message[alpha];

  DumInt := PutStream(2, MessageBuff, LenMessageBuff);

end;



Procedure InComm(var IncomingMessage: string);

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

var

  LengthBuff: integer;

  alpha: integer;

  IncomingBuff: array[1..255] of char;

begin

  LengthBuff := GetStream(2, IncomingBuff, 255);

  IncomingMessage[0] := char(LengthBuff);

  for alpha := 1 to LengthBuff do

    IncomingMessage[alpha] := IncomingBuff[alpha];

end;



{* Main Program *}

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

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

begin

  DumBool := CommOpen(2, 9600, 'N', 8, 1, 1000, 1000, false);

end.