home *** CD-ROM | disk | FTP | other *** search
/ The Unsorted BBS Collection / thegreatunsorted.tar / thegreatunsorted / hacking / phreak_utils_pc / bbp_conv.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1995-04-01  |  3.3 KB  |  115 lines

  1. unit bbp_conv;
  2.  
  3. interface
  4.  
  5. procedure convertccodes;
  6. procedure convertdocs;
  7.  
  8. implementation
  9.  
  10. uses bbp_vars, bbp_info, crt;
  11.  
  12. procedure convertccodes;
  13. var t        :text;
  14.     s        :string;
  15.     currec   :ccodetype;
  16.     target   :file of ccodetype;
  17.     numcodes :word;
  18. begin
  19.   writeln('BLUEBEEP CONVCC - Converting C-CODE.LST into country code database');
  20.   writeln;
  21.   writeln('start converting...');
  22.   assign(t,'C-CODE.LST');
  23.   reset(t);
  24.   assign(target,ccodefilename);
  25.   rewrite(target);
  26.   numcodes:=0;
  27.   while not eof(t) do begin
  28.     readln(t,s);
  29.     if (s[1]<>';') and (s<>'') then begin
  30.       inc(numcodes);
  31.       currec.cc:=copy(s,1,pos(' ',s)-1);
  32.       s:=copy(s,4,length(s)-3);
  33.       while s[1]=' ' do s:=copy(s,2,length(s)-1);
  34.       while s[length(s)]=' ' do s:=copy(s,1,length(s)-1);
  35.       currec.country:=s;
  36.       write(target,currec);
  37.     end;
  38.   end;
  39.   close(t);
  40.   close(target);
  41.   writeln(numcodes,' country codes converted.');
  42.   halt($FF);
  43. end;
  44.  
  45. procedure convertdocs;
  46. const inname  = 'BLUEBEEP.DOC';
  47.       outname = 'BLUEBEEP.TXT';
  48. var t          :text;
  49.     x,y        :word;
  50.     s          :string;
  51.  
  52. begin
  53.   colors.error:=white;
  54.   colors.error_reverse:=red*16+white;
  55.   writeln;
  56.   writeln('BLUEBEEP PLAINDOC - Converting documentation into plaintext ASCII txt');
  57.   writeln;
  58.   writeln('Action: Converting ',inname,' to ',outname);
  59.   writeln('Opening ',inname,' to build topic table');
  60.   readtopictable(inname);
  61.   writeln('Build of topic table completed');
  62.   writeln('Stripping color codes out of ',doclength,' lines');
  63.   for x:=1 to doclength do begin
  64.     s:='';
  65.     y:=0;
  66.     while length(document[x]^)>y do begin
  67.       inc(y);
  68.       if document[x]^[y]='|' then inc(y) else s:=s+document[x]^[y];
  69.     end;
  70.     document[x]^:=s;
  71.   end;
  72.   writeln('Opening output file ',outname);
  73.   assign(t,outname);
  74.   rewrite(t);
  75.   for y:=1 to 79 do write(t,'─');
  76.   writeln(t);
  77.   writeln(t,' ',docname,' - Table of Contents');
  78.   for y:=1 to 79 do write(t,'─');
  79.   writeln(t);
  80.   writeln(t);
  81.   for x:=1 to topiccount do begin
  82.     write(t,'  ',x:2,') ',topictable[x]^.topic);
  83.     for y:=1 to 70-length(topictable[x]^.topic)-length(topictable[x]^.subtitle)
  84.       do write(t,'.');
  85.     writeln(t,topictable[x]^.subtitle);
  86.   end;
  87.   writeln(t);
  88.   writeln(t,'      Total ',topiccount,' topic(s)');
  89.   writeln(t);
  90.   writeln(t,'Converted using PLAINDOC V1.00 from a Dr. Reader document');
  91.   writeln(t);
  92.   for x:=1 to topiccount do begin
  93.     write('Writing topic to output file: ',topictable[x]^.topic,'                 ',#13);
  94.     for y:=1 to 79 do write(t,'─');
  95.     writeln(t);
  96.     writeln(t,' ',topictable[x]^.topic,' - ',topictable[x]^.subtitle);
  97.     for y:=1 to 79 do write(t,'─');
  98.     writeln(t);
  99.     for y:=topictable[x]^.astart+1 to topictable[x]^.aend do writeln(t,'  ',document[y]^);
  100.     writeln(t);
  101.   end;
  102.   write(#10);
  103.   writeln('Closing files & freeing memory');
  104.   writeln(t);
  105.   for y:=1 to 79 do write(t,'─');
  106.   writeln(t);
  107.   writeln(t,' End of document                                       PLAINDOC (C) 1993 by OD');
  108.   for y:=1 to 79 do write(t,'─');
  109.   writeln(t);
  110.   close(t);
  111.   for x:=1 to doclength do dispose(document[x]);
  112.   writeln('Operation complete - ',outname,' successfully created on disk.');
  113.   halt(0);
  114. end;
  115. end.