home *** CD-ROM | disk | FTP | other *** search
/ POINT Software Programming / PPROG1.ISO / pascal / swag / textfile.swg / 0031_Text to EXE Conversion.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1993-11-02  |  1.3 KB  |  50 lines

  1. {
  2. > Do you have some code that will produce a Program that makes
  3. > self-viewing Text Files (like txt2com)?
  4.  
  5.  This adds a small Text File to a loader which simply reads through the
  6.  data and sends it to the ANSI driver, so it's good For ANSIs or Text
  7.  Files that will fit in one screen.
  8.  
  9.  However you could change the loader (if you know assembly) to do paUses
  10.  or output the File to STDOUT so you can use the more-pipe (|more).
  11. }
  12.  
  13. (* MakeMsg v0.00 - Public Domain by Robert Rothenburg 1993 *)
  14.  
  15. Program MakeMessage;
  16. Const
  17.   loader : Array [0..14] of Byte =
  18.       ($BE,$0F,$01,$B9,$00,$00,$FC,$AC,$CD,$29,$49,$75,$FA,$CD,$20);
  19. Var
  20.   fin, fout : File;
  21.   nin, nout : String;
  22.   buffer    : Array [0..4095] of Byte;
  23.   i         : Word;
  24.  
  25. begin
  26.   Writeln('"MakeMsg" v0.00');
  27.   if ParamCount <> 2 then
  28.     Writeln('Usage: MAKEMSG TextFile execFile')
  29.   else
  30.   begin
  31.     nin  := ParamStr(1);
  32.     nout := ParamStr(2);
  33.     Assign(fin, nin);
  34.     reset(fin, 1);
  35.     Assign(fout, nout);
  36.     reWrite(fout, 1);
  37.     i := Filesize(fin);
  38.     loader[4] := lo(i);
  39.     loader[5] := hi(i);
  40.     BlockWrite(fout, loader[0], 15);
  41.     Repeat
  42.       BlockRead(fin, Buffer[0], 4096, i);
  43.       BlockWrite(fout, Buffer[0], i)
  44.     Until i = 0;
  45.     close(fin);
  46.     close(fout);
  47.     Writeln('Done.');
  48.   end;
  49. end.
  50.