'WP2RTF - copyright 1997 Branko Collin ' 'The program below will convert text files from the Wordperfect 4.2 for DOS 'format to the Rich Text Format. ' 'It was intended to be nothing more than a prototype for the conversion 'program of the same name that I wrote in E. ' 'Please use this source only for educational purposes. Do not spread an 'executable of it. The program has not been tested extensively. It may 'contain bugs and I know for a fact that it does not convert WP to RTF 'very well. ' 'The source may be distributed by anyone. ' Set Buffer 100 'KNOWN contains the ascii-code numbers of the WP-codes that this program 'knows of. Dim KNOWN(13) For I=0 To 13 Read KNOWN(I) Next I Sort KNOWN(0) Data $A,$D,$94,$95,$9D,$9C,$A9,$AA,$B2,$B3,$BC,$BD,$DC,$E2 'NAAMIN$ contains the name of the file that is to be converted. NAAMIN$=Fsel$("") If NAAMIN$="" Then Stop If Not Exist(NAAMIN$) Then Stop Open In 1,NAAMIN$ FL=Lof(1) PM=FL/100 : If PM<1 Then PM=1 TEKSTIN$=Input$(1,FL) Close 1 'standard header TEKSTOUT$="{\rtf\ansi{\fonttbl\f0\fswiss dummy;}" 'enable footnotes and endnotes TEKSTOUT$=TEKSTOUT$+"\ftnbj\aenddoc\fet2" Global P P=1 LL=Len(TEKSTIN$) OUT=False Repeat A$=Mid$(TEKSTIN$,P,1) A=Asc(A$) M=Match(KNOWN(0),A) If M>=0 FOUND[TEKSTIN$,P,A] A$=Param$ TEKSTOUT$=TEKSTOUT$+A$ Else Inc P TEKSTOUT$=TEKSTOUT$+A$ End If Locate 0,0 Print " " Locate 0,0 Print LL;P If P>LL Then OUT=True Until OUT TEKSTOUT$=TEKSTOUT$+"}" ' NAAMOUT$=Fsel$("*.rtf","","Write RTF-file as...") If NAAMOUT$="" Then Stop Open Out 1,NAAMOUT$ Print #1,TEKSTOUT$; Close 1 Centre("The end.") Print ' End ' Procedure FOUND[A$,B,C] Z$="" 'hidden hyphen or soft return If((C=$D) or(C=$AA)) Z$=" " Inc P End If 'bold on If C=$9D Z$="\b " Inc P End If 'bold off If C=$9C Z$="\b0 " Inc P End If 'italics on If C=$B2 Z$="\i " Inc P End If 'italics off If C=$B3 Z$="\i0 " Inc P End If 'underline on If C=$94 Z$="\ul " Inc P End If 'underline off If C=$95 Z$="\ul0 " Inc P End If 'hyphen If C=$A9 Z$="-" Inc P End If 'strip subscript and superscript If((C=$BC) or(C=$BD)) Inc P Z$="" End If 'hard return If C=$A If P<>Len(A$) Inc P If Asc(Mid$(A$,P,1))=$A Z$="\line " Else Z$="\par " End If Else Z$="\par " Inc P End If End If 'page break If C=$DC OUT2=False LL=Len(A$) TT=0 Repeat Inc P Inc TT C=Asc(Mid$(A$,P,1)) If P=L OUT2=True End If If TT>9 OUT2=True End If If C=$C OUT2=True End If Until OUT2 Z$="\page " Inc P End If 'foot- or endnote If C=$E2 OUT2=False LL=Len(A$) TT=0 Repeat Inc P Inc TT C=Asc(Mid$(A$,P,1)) If P=LL OUT2=True End If If TT>20 OUT2=True End If If C=$8D OUT2=True End If Until OUT2 OUT2=False Z$="{\super\chftn{\footnote\plain{\super\chftn}{" Repeat Inc P C=Asc(Mid$(A$,P,1)) If P=LL OUT2=True End If If C=$E2 OUT2=True Else Z$=Z$+Chr$(C) End If Until OUT2 Z$=Z$+"}}}" Inc P : Inc P End If End Proc[Z$]