home *** CD-ROM | disk | FTP | other *** search
/ ftp.barnyard.co.uk / 2015.02.ftp.barnyard.co.uk.tar / ftp.barnyard.co.uk / cpm / walnut-creek-CDROM / MBUG / MBUG005.ARC / WB-ESC.DOC < prev    next >
Text File  |  1979-12-31  |  6KB  |  158 lines

  1.                        WORDBEE_FILE_CONVERTER.
  2.                                                   B∙ Steveε Jepson.
  3.  
  4.      Thi≤á prograφá wa≤ writteε fo≥ peoplσ wh∩ havσ ß disδ systeφá anΣá usσ ì
  5. Wordbeσ a≤ thei≥ Editor«á Wordbeσ ha≤ thσ advantagσ oµ allowinτ yo⌡ t∩á usσ ì
  6. al∞ oµ you≥ printer'≤ escapσ codes« However¼ t∩ usσ thi≤ facility¼ yo⌡ mus⌠ ì
  7. jum≡á t∩á thσá monitor╗á manuall∙á inser⌠á thσá escapσá character≤á iεá thσ ì
  8. appropriatσ places╗ jum≡ bacδ t∩ wordbeσ anΣ savσ thσ file« Thi≤ i≤ ß mess∙ ì
  9. procedurσ whicΦ caε producσ BDO╙ error≤ unles≤ grea⌠ carσ i≤ takeε and¼ fo≥ ì
  10. thσ novice¼ thi≤ i≤ aε almos⌠ impossiblσ task.
  11.  
  12.      T∩á usσá thi≤ prograφ ß certaiε characte≥ i≤ pu⌠ iε thσá Wordbeσá filσ ì
  13. (usinτá WordBee⌐á wherσá thσá Escape≤ arσ wanteΣá (thi≤á characte≥á caεá bσ ì
  14. determineΣá b∙ thσ use≥ a⌠ compilatioε anΣ i⌠ i≤ currentl∙ se⌠ a⌠ `^'⌐ Wheε ì
  15. thσá prograφá i≤ theε ruε al∞ thσ `^'≤ arσ converteΣ t∩á Escapσá character≤ ì
  16. whicΦ wil∞ appea≥ a≤ ß O'≤ witΦ horizonta∞ line≤ througΦ thσ middle«á Thesσ ì
  17. caεá bσá deleteΣ iε WordBeσ bu⌠ caε no⌠ bσ created¼á s∩ iµ b∙á acciden⌠á aε ì
  18. escapσá i≤ deleted¼á anothe≥ `^º shoulΣ bσ addeΣ anΣ thσ filσá ruεá througΦ ì
  19. thi≤ prograφ again.
  20.  
  21.      Thσ prograφ wil∞ producσ ß backu≡ filσ oµ thσ filσ i⌠ i≤ convertinτ s∩ ì
  22. that¼á iµ ß mistakσ i≤ made¼ thσ filσ caε bσ retrieved« I⌠ wil∞ als∩ deletσ ì
  23. thσ olΣ backu≡ filσ beforσ thσ ne≈ onσ i≤ made¼á thi≤ wil∞ sto≡ yo⌡á havinτ ì
  24. 1░ olΣ backu≡ files.
  25.  
  26.      Thσá prograφ wil∞ looδ oε thσ curren⌠ drivσ fo≥ thσ filσ unles≤ ß disδ ì
  27. namσá i≤á giveεá iεá thσ filename«á D∩ no⌠ adΣá thσá filetypσá `.WBFºá wheε ì
  28. specifyinτ thσ filenamσ a≤ thσ prograφ add≤ thi≤ itself.
  29.  
  30.      Thσá codσá i≤á iε Turb∩ Pasca∞ anΣ wil∞ havσ t∩ bσá compileΣá t∩á disδ ì
  31. becausσ oµ thσ sizσ oµ thσ buffe≥ array« Therσ wil∞ bσ ß cop∙ oµ thσ objec⌠ ì
  32. codσ anΣ sourcσ codσ oε thσ club'≤ RCPM¼ and¼ iµ i⌠ i≤ no⌠ possiblσ fo≥ yo⌡ ì
  33. t∩á ge⌠ ß cop∙ ofµ thσ RCPM¼á ß cop∙ wil∞ bσ pu⌠ iε thσ tapσá librar∙á witΦ ì
  34. botΦá file≤á oεá it«á (Thesσ wil∞ onl∙ bσ fo≥ disδ systems.⌐  Thσá filσá i≤ ì
  35. commenteΣ anΣ iµ therσ arσ an∙ problem≤ witΦ thσ prograφ yo⌡ caε seσ mσá a⌠ ì
  36. thσ nex⌠ meetinτ o≥ leavσ message≤ oε thσ RBBS.
  37.  
  38.      Iµá yo⌡á don'⌠ usσ WordBeσ thσ prograφ coulΣ bσá modifieΣá t∩á perforφ ì
  39. task≤ sucΦ a≤ filσ compactinτ o≥ filσ copying.
  40.  
  41.  
  42.                                Thσ_Program.
  43.  
  44. Prograφ Wordbee_ESC_Converter;
  45.  
  46.  const
  47.    Name_lengtΦ ╜ 14;
  48.    Bufsizσ     ╜ 250;
  49.    Bufbytesizσ ╜ 32000;
  50.    Change_cha≥ ╜ 94╗  √ ▐ }
  51.  
  52.  Type
  53.    Namσ ╜ String[Name_length]╗  √ T∩ savσ filename≤ iε }
  54.  
  55.  Var
  56.    Filename                 : Name; { Where the filename is kept}
  57.    Master_File,
  58.    New_File                 : File; { File variables }
  59. è   { Buffer is where Blockread and Blockwrite keep the 
  60.        information which has been read from the file   }
  61.    Buffer                   : Array[1..Bufbytesize] of Byte;
  62.    Recs_To_Read,
  63.    Remaining,
  64.    I                        : Integer;
  65.    No_Error                 : Boolean;
  66.  
  67.  
  68.  
  69. Function Exist(Filename :Name) :Boolean;
  70.  
  71.   {  Finds if the file already exists on the Disk. }
  72.   {   If so returns TRUE. }
  73.  var
  74.    Fil : file;
  75.  
  76.  Begin
  77.    Assign(Fil,Filename);
  78.    {$I-}  Reset(fil) {$I+}; { Errors are captured not reported }
  79.    if IOresult <> 0 then Exist := False else Exist := True;
  80.  end;
  81.  
  82.  
  83. Begin
  84.   ClrScr;
  85.   Writeln('WordBee ESC Converter.':52);
  86.   writeln('~~~~~~~~~~~~~~~~~~~~~~':52);
  87.   Writeln(' By S.Jepson 20/1/85':78);
  88.   Writeln;Writeln;writeln;
  89.   Write('This Program will find a certain Character ');
  90.   Writeln('and convert it to the ESC character');
  91.   Write('in the Wordbee file. It also produces a Backup of ');
  92.   writeln('the original file.');
  93.   Writeln;writeln;writeln;writeln;
  94.   Writeln('Enter the name of the WordBee file , only the name.');
  95.   Writeln;
  96.   Write('eg  ''FRED''  NOT  ''FRED.WBF''   Filename :');
  97.   Filename:='                         ' ;
  98.   Readln(Filename);
  99.        { Change to Upper Case }
  100.   For I := 1 to Name_length do
  101.       Filename[I] := UpCase(Filename[I]);
  102.  
  103.   IF Exist(Filename+'.WBF') { See if file is on disk}
  104.      Then
  105.       Begin
  106.  
  107.        If Exist(Filename+'.BAK') { erase old backup}
  108.          then begin
  109.                 Assign(New_File,Filename+'.BAK');
  110.                 Erase(New_File);
  111.               end;
  112.  
  113.        Assign(Master_File,Filename+'.WBF'); {Create a backup   }
  114.        Rename(Master_File,Filename+'.BAK'); {file of masterfile}
  115.  
  116.        Assign(New_File,Filename+'.WBF'); {Open newfile in the }
  117.                                          { oldfiles name      }è       Rewrite(New_File);  { clear the new file }
  118.        Reset(Master_File); { point to start of master file }
  119.  
  120.        No_Error := True;  { there are no errors }
  121.        Remaining := Filesize(Master_File); {what is size of file}
  122.  
  123.        While ( Remaining > 0 ) and No_Error do {do until EOF }
  124.         Begin
  125.              { how much can we read from master file ?? }
  126.          If Bufsize <= Remaining Then
  127.                                    Recs_To_Read := Bufsize
  128.                                  Else
  129.                                    Recs_To_Read := Remaining;
  130.  
  131.               { Read the block of file and disable I/O errors }
  132.          {$I-}  Blockread(Master_File,Buffer,Recs_To_Read)  {$I+};
  133.  
  134.               { If there was an error then EOF has occurred }
  135.          If  Ioresult <> 0 Then No_Error := False;
  136.  
  137.               { Change all `change_char's to ESC }
  138.          For I:=1 To Recs_To_Read*128 do
  139.               If Buffer[I] = Change_Char Then Buffer[I]:= 27;
  140.  
  141.               { Write the changed block of file to new file }
  142.          Blockwrite(New_File,Buffer,Recs_To_Read);
  143.  
  144.               { How much of Master File is left to read }
  145.          Remaining := Remaining - Recs_To_Read;
  146.         End; {of while loop}
  147.  
  148.        Close(Master_File); {close files}
  149.        Close(New_File);
  150.       End {of if then}
  151.  
  152.     Else {File does not exist. Produce Error.}
  153.      begin
  154.      writeln;writeln;
  155.      Writeln('..FILE_ERROR.. File ',filename,'.WBF does not exist.');
  156.      end;
  157. End. { of program }
  158.