NOTEPAD TO .RTF FILE CONVERTER ------------------------------ Mark Ray, 13 Dec 1996, released under GPL. Translation of the work of Maksim Lin. This BBC BASIC version has preserved the algorithm of the original: Open input and output files 1 Output header block Repeat: Read a character 2 If &05 then output a code If &0A then output linefeed string If &8A then ignore 3 If {, \ or } then prefix with a \ Else output character Until end of input file Send footer block Close files 2: Output a code reads the next character to determine which formatting (bold/italic/etc.) is being toggled and toggles an array of flags accordingly. The resulting control string is then output. 1: The header block now credits the program as the document author. 3: This has been added, from my understanding of the RTF syntax. IMPLEMENTATION NOTES: Works faster on text which isn't right justified. Beeps when done. Leaves some Notepad formatting codes, beginning with a >, lying around. Probably could translate these too, but text is normally reformatted on the PC, anyway. The bits of the integer variable F% are used as flags and stand for (LSB first): nothing, bold, italic, underline, subscript, superscript and enlarged. The characters for these effects are held in the variable F$ in the same order: bold, italic ... enlarged. Occasionally, BPUT# is used, as PRINT# insists on putting a carriage return at the end of the output string. The "hack" in the original C code does not appear to be necessary here. Who said C's better than BASIC? This program took 2 hours total development, while watching TV and with a system crash blanking the memory near the end! At the time of writing, my email address (for bug reports, comments, etc.) is M.Ray@UEA.ac.uk - if you develop this code further, I'd like to hear about it.