1. Introduction
Recently, bought a 900 English learning CD-ROM, because there is no corresponding written material, I would like to own the CD documents extracted, can open a CD, found that although each sentence has a corresponding detailed text material, But each sentence is stored separately in a separate RTF document (Sentence001.rtf to SENTENCE900.RTF), which is cumbersome to use, so you want to merge all 900 sentence patterns together, merging 900 separate documents into one document.
2. How to Solve
2.1 Conventional methods
The first idea is to take advantage of the document merge feature of Word to insert another Word document into the currently open document. The specific steps are:
① opens sentence001 (in the dialog for opening a file, the file type chooses Rich Text format).
② position the cursor at the end of the document.
③ Click the "File ..." menu item in the Insert menu.
④ in the Open Insert File dialog box, enter the name of the file you want to insert in the file name box: sentence002.rtf
This combines the two documents of the first two sentences into a single document and exists as a sentence001.rtf. Obviously, as long as you repeat the above process, you will eventually merge the 900 sentence patterns scattered in 900 documents into one document. The process is simple, but time-consuming, and therefore applies only to a handful of document merging operations.
The application of 2.2 Delphi in document merging
Taking into account the following:
(1) Each file name to be merged with "sentence" Start, followed by 001, 002,...,900, very regular.
(2) When merging, each time the contents of the new document are added to the end of the original document, inserted at the end of the original document, the insertion position is fixed.
There is no quicker way to think about it, and it's better for the computer to automatically help complete the merge process.
① idea: In Delphi, select a control that can accept and handle multi-line text, first read sentence001.rtf content into it, then loop, then Sentence002.rtf, The contents of the sentence003.rtf are read in and appended to the end, and the contents of the control are finally saved to another file.