Apply Script Function - RTF Example

This example of the Apply Script function shows how the function may be used to handle plain text equivalents of upper ascii characters in rtf documents. If you were to search an rtf file for the characters "Σ" or "ⁿ" there would either be no search hits because these characters are coded as "\'e4" and "\'fc" (no quotes) in rtf. Conversely, a direct replace involving "Σ" or "ⁿ" would likely corrupt the rtf. The Apply Script function can be used to process the search (or replace) string to quickly change instances of "Σ" or "ⁿ" to their rtf counterparts.

Steps

1. Begin by creating a script to perform the transforms using the Script Dialog or manually, using a text editor. A simple conversion script for "Σ" and "ⁿ" is:

[Script for Search and Replace]

Comment: Double \\ is needed because \ is a Search

and Replace reserved character. In the actual RTF

document, Σ is coded with as \'e4.and ⁿ is coded as \'fc

[Search /i]

Σ

[Replace]

\\'e4

[Search /i]

[Replace]

\\'fc

[End of Search and Replace Script]

 

This script can be any name. The name, "rtf tranform example.srs", will be used here.

2. To use rtf tranform example.srs in the Apply Script function, open the Binary Mode dialog and enter the string "fⁿr komplexe oder hΣufig" (no quotes) into the dialog.

image\s_bin4a_shg.gif

3. Click the Apply Script button, navigate to where rtf tranform example.srs is saved, and select it.

4. Click the "Open" button. rtf tranform example.srs will operate on the search (or replace) string and "fⁿr komplexe oder hΣufig" will be changed to "f\\'fcr komplexe oder h\\'e4ufig"

image\s_bin4b_shg.gif

5. Click the OK button to use the transformed string to conduct your primary search (or replace).

Also see: [HTML Example] [Reg Exp Reserved Characters Example] [Apply Script Function Overview]