{= EXPORT.PAS ===========================================================
|
| Export - Sample Export Program for HyperMail<>WAMFormat, Version 0.0
|
| Jonathan Gillies, Code Masters, Inc.
|
|========================================================================
|
|========================================================================}
PROGRAM Export;

USES
  Crt, Dos;

CONST
  ProgramName  = 'EXPORT';
  ProgramDesc  = 'Sample Export Program for HyperMail<>WAMFromat';
  ProgramVers  = '0.0';

  ExportFileName : String[10] = 'EXPORT.TXT';
  WAMVersionSupported = '01.00';

{$I COMMON.INC}    { Common Functions/Procedures }
{$I WAM.TYP}       { WAM Format type declarations }
{$I TOOLS.INC}     { Tools used by WAM-IO.INC }
{$I WAM-IO.INC}    { WAM Format Utilities }

VAR
  ConversionTable : ConversionTableType;
  ConversionCount : Byte;
  SystemType      : Char;
  SystemId        : String[8];
  Junk            : String;
  WamMessage      : WamMessagePointer;
  WAMFile         : Text;
  AreaNumber      : Byte;

{$I NATIVE.INC}    { Native Message/File Declarations/Procs }

{ Variable declarations based on NATIVE.INC }
VAR
  NativeFile      : NativeFileType;
  NativeMessage   : NativeMessageType;
  NativeAreaPath  : NativeAreaPathType;
  NumberOfAreas   : Byte;
  MessagePointer  : PointerArrayType;

{------------------------------------------------------------------------
|
|
|------------------------------------------------------------------------}
PROCEDURE CheckDisk;
BEGIN
  IF IOResult = 0 THEN Exit;
  Writeln ('Disk error!');
  Halt(255);
END;

{------------------------------------------------------------------------
|
|
|------------------------------------------------------------------------}
PROCEDURE PositionMessagePointer (VAR NativeFile    : NativeFileType;
                                      MessageNumber : Word);
BEGIN
END;

{------------------------------------------------------------------------
|
|
|------------------------------------------------------------------------}
PROCEDURE ReadNativeFormatMessage (VAR NativeFile     : NativeFileType;
                                   VAR NativeMessage  : NativeMessageType);
BEGIN
END;

{------------------------------------------------------------------------
|
|
|------------------------------------------------------------------------}
PROCEDURE ConvertNativeToWam (VAR NativeMessage     : NativeMessageType;
                              VAR WAMFormatMessage  : WAMMessagePointer);
BEGIN
END;

{========================================================================
 ==========                         Main                         ========
 ========================================================================}
BEGIN
  Writeln;
  Writeln (ProgramName,' - ',ProgramDesc,', V',ProgramVers);
  Writeln;

  SystemId:= ParamStr(1);
  Junk:= ParamStr(2);
  SystemType:= UpCase(Junk[1]);
  IF (SystemId = '') OR (SystemType <> 'H') OR (SystemType <> 'N') THEN BEGIN
    Writeln ('Invalid command line parameters!');
    Writeln;
    Writeln ('Usage:  EXPORT SystemId SystemType');
    Halt(255);
  END;

  { Read the Conversion Table }
  IF NOT ReadConversionTable (ConversionTable, ConversionCount,
                              SystemId, SystemType) THEN BEGIN
    Writeln (^g^g'Error reading conversion table!');
    Halt (255);
  END; { IF }

  { Read information about the native message bases }
  GetNativeInformation (NativeAreaPath, NumberOfAreas);

  { Open the EXPORT.TXT file for write }
  Assign (WAMFile, ExportFileName);
  {$I-} Rewrite (WAMFile); {$I+} CheckDisk;

  New (WAMMessage);

  FOR AreaNumber:= 1 TO NumberOfAreas DO BEGIN
    Assign (NativeFile, NativeAreaPath[AreaNumber]);
    {$I-} Reset (NativeFile); {$I-} CheckDisk;

    PositionMessagePointer (NativeFile, MessagePointer[AreaNumber]);

    ReadNativeFormatMessage (NativeFile, NativeMessage);

    ConvertNativeToWAM (NativeMessage, WAMMessage);

    WAMMessage^.Area:= AreaNumber;

    WriteWAMMessage (WAMFile, WAMVersionSupported, WAMMessage);
  END; { FOR }

  Dispose (WAMMessage);

  {$I-} Close (WAMFile); {$I+} CheckDisk;
  {$I-} Close (NativeFile); {$I-} CheckDisk;

END.

