home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / progm / tptools.zip / BINED.ZIP / SIMPLE.PAS < prev   
Pascal/Delphi Source File  |  1987-12-21  |  1KB  |  31 lines

  1. {                          SIMPLE.PAS
  2.              Copyright (c) 1985, 87 by Borland International, Inc.            }
  3.  
  4. program Simple;              {SIMPLE.PAS: A simple editor using the BINED unit}
  5.  
  6. uses BinEd, Crt;
  7.  
  8. const ExitCommands : Char = #0;                        {No extra exit commands}
  9. var   EdData : EdCB;                                     {Editor control block}
  10.  
  11.   procedure Abort(Msg : String);
  12.   begin  {Abort}
  13.     GotoXY(1, 25); Write(Msg); Halt(1);
  14.   end;   {Abort}
  15.  
  16. begin
  17.   if (ParamCount = 0) then                                        {No filename}
  18.      Abort('Usage: SIMPLE filename.ext');
  19.   if (InitBinaryEditor(EdData, MaxFileSize, 1, 1, 80, 25, {Initialize a window}
  20.      True, EdOptInsert, '', ExitCommands, nil) <> 0) then{Couldn't load editor}
  21.        Abort('Unable to load binary editor.');
  22.   if (ReadFileBinaryEditor(EdData, ParamStr(1)) > 1) then  {Couldn't read file}
  23.      Abort('Unable to read ' + ParamStr(1));
  24.   ResetBinaryEditor(EdData);                               {Reset for new file}
  25.   if (UseBinaryEditor(EdData, '') = -1) then                    {Edit the file}
  26.      if ModifiedFileBinaryEditor(EdData) then                {Was it modified?}
  27.         if (SaveFileBinaryEditor(EdData, True) <> 0) then             {Save it}
  28.            Abort('Error saving file.');
  29.   GotoXY(1,25);
  30. end.
  31.