{= WAMDISP.PAS ==========================================================
|
| WAMDisp - Wide Area Message Format Display Code, Version 1.0
|
| Jonathan Gillies, (C) 1990, WAM Committee
|
|========================================================================
| Turbo Pascal 5.x Code.
|========================================================================}
PROGRAM WAMDisp;

USES
  Crt, Dos;

CONST
  ProgramName  = 'WAMDISP';
  ProgramDesc  = 'Wide Area Message Format Display';
  ProgramVers  = '1.0';

{$I TOOLS.INC}     { Conversion Tools }
{$I WAM.TYP}       { WAM Const and TYPE Declarations }
{$I WAM-IO.INC}    { WAM Disk Read/Write procedures }
{$I WAM-DI.INC}    { WAM Screen Display procedures }

VAR
  InputFileName               : String;

{------------------------------------------------------------------------
|
|
|------------------------------------------------------------------------}
PROCEDURE Abort (Msg  : String);

BEGIN
  Writeln (Msg);
  Halt (99);
END;


{------------------------------------------------------------------------
|
|
|------------------------------------------------------------------------}
PROCEDURE DisplayWAMFile (FileName  : String);

VAR
  InputFile                   : Text;
  Data                        : String;
  WAMMessage                  : WAMMessagePointer;
  Version                     : String;

BEGIN
  New(WAMMessage);
  Assign (InputFile, FileName);
  {$I-} Reset (InputFile); {$I+}
  IF IOResult <> 0 THEN Abort ('Could not open '+FileName);

  { Get the version information }
  Readln (InputFile, Data);
  IF Copy(Data,1,8) <> 'VERSION:' THEN
      Abort ('Expecting "VERSION:" but found "'+Data+'"');

  Version:= Copy(Data,10,5);

  WHILE NOT Eof(InputFile) DO BEGIN
    ReadWAMMessage (InputFile, Version, WAMMessage);
    DisplayWAMMessage (Version, WAMMessage);
  END;

  {$I-} Close (InputFile); {$I+}
  IF IOResult <> 0 THEN Abort ('Could not close '+FileName);

  Dispose(WAMMessage);
END;

{========================================================================
 ==========                         Main                         ========
 ========================================================================}
BEGIN
  Writeln;
  Writeln;
  Writeln (ProgramName+' -  Version '+ProgramVers+'  Copyright (c) 1990 WAM Committee.');
  Writeln ('           '+ProgramDesc);
  Writeln;

  { Allow DOS Redirection }
  Assign (Input, '');
  Assign (OutPut, '');
  Reset (Input);
  Rewrite (Output);

  InputFileName:= ParamStr(1);
  IF InputFileName = '' THEN BEGIN
    Writeln ('USAGE:');
    Writeln ('       WAMDISP WAMFormatedFileName');
    Halt (99);
  END;

  DisplayWAMFile (InputFileName);

END.

