home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / mksmvp10.zip / msgexprt.rar / MSGEXPRT.PAS < prev   
Pascal/Delphi Source File  |  1997-09-28  |  2KB  |  104 lines

  1. Program MsgExprt;
  2.  
  3. {$I MKB.Def}
  4.  
  5. {$X+}
  6.  
  7. {$IFDEF WINDOWS}
  8. Uses MKWCrt,
  9. {$ELSE}
  10.   {$IFDEF OPRO}
  11.   Uses OpCrt,
  12.   {$ELSE}
  13.   Uses Crt,
  14.   {$ENDIF}
  15. {$ENDIF}
  16. MKMsgAbs, MKOpen, MKDos, MKstring
  17. {$IFDEF VIRTUALPASCAL}
  18. , Use32
  19. {$ENDIF};
  20.  
  21. Var
  22.   MsgOut: AbsMsgPtr;
  23.   TmpStr: String;
  24.   AreaId: String;
  25.   OutFile: Text;
  26.   OutName: String;
  27.   TempX : Word;
  28.  
  29. Const
  30.   StLen = 78;
  31.  
  32. Begin
  33. If (ParamCount < 2) or (ParamStr(1) = '/?') Then
  34.   Begin
  35.   WriteLn('Proper syntax is:');
  36.   WriteLn('MsgExprt OutPut.Txt MsgAreaId');
  37.   WriteLn;
  38.   WriteLn('   Squish MsgAreaId Example = SC:\Max\Msg\Muffin');
  39.   WriteLn('   Hudson MsgAreaId Example = H042C:\MK\MsgBase');
  40.   WriteLn('   *.Msg  MsgAreaId Example = FC:\Mail');
  41.   WriteLn('   Ezy    MsgAreaId Example = E0001C:\Ezy\MsgBase');
  42.   WriteLn('   Jam    MsgAreaId Example = JC:\Msg\General');
  43.   WriteLn;
  44.   Halt(1);
  45.   End;
  46. AreaId := Upper(ParamStr(2));
  47. OutName := Upper(ParamStr(1));
  48. WriteLn('Exporting to ', OutName);
  49. Assign(OutFile, OutName);
  50. ReWrite(OutFile);
  51. If IoResult <> 0 Then
  52.   Begin
  53.   WriteLn('Unable to create output file');
  54.   Halt(3);
  55.   End;
  56.   {If Not} OpenMsgArea(MsgOut, AreaId) {Then
  57.   Begin
  58.   WriteLn('Unable to open message base');
  59.   Halt(4);
  60.   End};
  61. WriteLn;
  62. WriteLn;
  63. MsgOut^.SeekFirst(1);
  64. While MsgOut^.SeekFound Do
  65.   Begin
  66.   WriteLn(OutFile, '--------------------------------------------------------------------------');
  67.   MsgOut^.MsgStartUp;
  68.   WriteLn(MsgOut^.GetMsgNum);
  69.   Write(OutFile, 'Message Number: ' + Long2Str(MsgOut^.GetMsgNum));
  70.   If MsgOut^.IsPriv Then
  71.     Write(OutFile,'  (Priv)');
  72.   If MsgOut^.IsRcvd Then
  73.     Write(OutFile, ' (Rcvd)');
  74.   WriteLn(OutFile);
  75.   Write(OutFile, 'From: ' + PadRight(MsgOut^.GetFrom,' ',45));
  76.   Write(OutFile, 'Date: ');
  77.   WriteLn(OutFile, ReformatDate(MsgOut^.GetDate, 'MM/DD/YY')
  78.     + ' ' + MsgOut^.GetTime);
  79.   WriteLn(OutFile, 'To: ' + MsgOut^.GetTo);
  80.   Write(OutFile, 'Subj: ');
  81.   WriteLn(OutFile,MsgOut^.GetSubj);
  82.   WriteLn(OutFile);
  83.   MsgOut^.MsgTxtStartUp;
  84.   TmpStr := MsgOut^.GetString(StLen);
  85.   While (Not MsgOut^.EOM) Do
  86.     Begin
  87.     WriteLn(OutFile, TmpStr);
  88.     TmpStr := MsgOut^.GetString(StLen);
  89.     End;
  90.   If Length(TmpStr) > 0 Then
  91.     WriteLn(OutFile, TmpStr);
  92.   If IoResult <> 0 Then;
  93.   MsgOut^.SeekNext;
  94.   End;
  95. Close(OutFile);
  96. If IoResult <> 0 Then
  97.   Begin
  98.   WriteLn('Error in output file');
  99.   Halt(3);
  100.   End;
  101. If Not CloseMsgArea(MsgOut) Then;
  102. End.
  103.  
  104.