home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / INFO / TURBOPAS / TXT2RND.ZIP / TXT2RND.PAS
Encoding:
Pascal/Delphi Source File  |  1985-12-28  |  2.3 KB  |  102 lines

  1. {$C-}
  2. Program CONVERT (  Input, Output );
  3.  
  4. Type
  5.  AnyString = String [ 12 ];
  6.  Name      = String [ 12 ];
  7.  Str12     = String [ 12 ];
  8.  Rec       = Record
  9.               Line : String [ 80 ];
  10.              End;
  11.  
  12. VAR
  13.  A, G, End_Of_File  : Integer;
  14.  OK                 : Boolean;
  15.  Line               : String [ 80 ];
  16.  Text_File          : Text [ $1000 ];
  17.  Random_File        : File of Rec;
  18.  Random_Line        : Rec;
  19.  Input, Output      : String [ 12 ];
  20.  
  21. Procedure Initialize_Variables;
  22. Begin
  23.  A := 0;
  24.  G := 0;
  25. End;
  26.  
  27. Function StUpCase ( St : AnyString ) : AnyString;
  28. Var I : Integer;
  29. Begin
  30.  For I := 1 to Length ( St ) do
  31.   St [ I ] := UpCase ( St [ I ] );
  32.  StUpCase := St
  33. End;
  34.  
  35. Procedure Stop ( FileVar : Str12 );
  36. Begin
  37.  ClrScr;
  38.   WriteLN ( ^G, StUpCase ( FileVar ), ' not found.' );
  39.  Halt;
  40. End;
  41.  
  42. Procedure Convert ( Input, Output : Str12 );
  43. Begin
  44. Write ( 'Opening Files...' );
  45.   Reset ( Text_File );
  46.  Assign ( Random_File, Output );
  47.   ReWrite ( Random_File );
  48. Write ( 'Converting...' );
  49.  With Random_Line do
  50.   Begin
  51.    While Not Eof ( Text_File ) do
  52.     Begin
  53. Line := '                                                                               ';
  54.      ReadLN ( Text_File, Line );
  55.      Write ( Random_File, Random_Line );
  56.    End;
  57.  End;
  58. {    Reset ( Random_File );
  59.    With Random_Line do
  60.     Begin
  61.      While Not Eof ( Random_File ) do
  62.       Begin
  63.        A := A + 1;
  64.       Seek ( Random_File, A );
  65.        Read ( Random_File, Random_Line );
  66.         WriteLN ( Line );
  67.      End;
  68.     End; }
  69. Write ( 'Closing Files...' );
  70.     Close ( Text_File );
  71.     Close ( Random_File );
  72. Write ( 'Done.' );
  73. End;
  74.  
  75. Procedure Ask_Names;
  76. Begin
  77. ClrScr;
  78. WriteLN ( 'Program to convert a TEXT file into a RANDOM file (field length 80)' );
  79. WriteLN ( 'that can be read by TURBO. By Jon Bauer: (203)-281-7287 *DATA*' );
  80.  WriteLN;
  81.  Write ( 'Input (TEXT) file name: ' );
  82.   BufLen := 12;
  83.  ReadLN ( Input );
  84.   If ( Input = '' ) Then Ask_Names;
  85.      Assign ( Text_File, Input );
  86.    {$I-}
  87.     Reset ( Text_File );
  88.    {$I+};
  89.    OK := (IOresult = 0 );
  90.    If Not OK Then Stop ( Input );
  91.  Write ( 'Output (RANDOM) file name: ' );
  92.   BufLen := 12;
  93.  ReadLN ( Output );
  94.   If ( Output = '' ) Then Ask_Names;
  95. End;
  96.  
  97. Begin
  98.   Initialize_Variables;
  99.   Ask_Names;
  100.   Convert ( Input, Output );
  101. End.
  102.