SOFTPACK.PAS 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. {$C+}
  2. {$R+}
  3. {$U+}
  4. program PACK;
  5. const recsize = 450;
  6. EOL = #$0D;
  7. infile_name = 'SOFTPORN.TXT';
  8. outfile_name = 'SOFTPORN.MSG';
  9. type rectype = array[1..recsize] of char;
  10. str = string[120];
  11. var line : str;
  12. rec : rectype;
  13. infile : text;
  14. outfile : file of rectype;
  15. i : integer;
  16. recpos : integer;
  17. procedure clearrec;
  18. var i : integer;
  19. begin
  20. recpos := 1;
  21. for i:=1 to recsize do
  22. rec[i] := chr(0);
  23. end;
  24. procedure addrec( c : char);
  25. begin
  26. if recpos>recsize then
  27. begin
  28. writeln('Record overflow in :');
  29. writeln(line);
  30. halt;
  31. end;
  32. rec[recpos] := c;
  33. recpos := recpos + 1;
  34. end;
  35. procedure dumprec;
  36. begin
  37. if recpos>1 then
  38. begin
  39. write( outfile, rec );
  40. write( recpos:4 );
  41. end;
  42. clearrec;
  43. end;
  44. begin { Main program }
  45. writeln('Converting ',infile_name,' to ',outfile_name,'. Recsize=',recsize);
  46. writeln;
  47. assign(infile,infile_name);
  48. assign(outfile,outfile_name);
  49. reset(infile);
  50. rewrite(outfile);
  51. clearrec;
  52. randomize;
  53. while not eof(infile) do
  54. begin
  55. readln( infile, line );
  56. if copy(line,1,3)='###' then
  57. dumprec
  58. else if line<>'' then
  59. begin
  60. for i:=1 to length(line) do
  61. addrec(succ(line[i]));
  62. addrec(EOL);
  63. end;
  64. end;
  65. dumprec;
  66. close(infile);
  67. close(outfile);
  68. writeln;
  69. end.
  70.