When you are working in a word processor, you often need to find a particular place in your document. MegaDots' Simple find command finds whatever text you ask for. This easy-to-use command is just the beginning of the flexibility and power offered by the find and replace features. You can find and replace something as simple as a specific word or something as complex as the first semicolon in each paragraph of a list. You can save one or more find and replace instructions in a rules file to automatically fine tune your documents. Empowered by these multi-purpose tools for processing text, some MegaDots users have turned into find and replace junkies.
In this chapter we introduce the different ways to find text and substitute replacement text. Since these features give you so many choices, we provide a variety of examples. The examples show how to use find and replace effectively, and you may find some which are very useful in your everyday work. We also list the easy-to-use rules files supplied with the MegaDots program and describe the important tasks they perform.
From the MegaDots editor, go to the Tools Menu by pressing F10 T. Press F to select the Find and Replace Menu. In this menu there are seven options along with corresponding shortcut command keys. These are the commands described in this chapter.
With Simple find you can search either forwards or backwards for specific text. To begin a search, press F9 to search forwards, or press Shift-F9 to search backwards. At any point, you can continue your most recent search by pressing Control-N for the Next occurrence or Control-L for the Last occurrence. If your search doesn't find a match, you can search in the other direction with Control-L or Control-N.
There are two different ways of searching for specific text. You may be concerned with matching the letter case exactly in your search. This kind of search is called case sensitive because it pays attention to, or is sensitive to, letter case. Or you may wish to ignore letter case in your search. This kind of search is called case insensitive because it is not sensitive to letter case. When the text you enter in Simple find has at least one uppercase letter, MegaDots assumes that letter case is significant and does a case sensitive search. When you enter text with only lowercase letters, MegaDots assumes that letter case is not important and does a case insensitive search. When you really do need a case sensitive search on search text that contains all lowercase letters, it is easy to do with Complex find, as described later.
C:\Program Files\Mega23\chicken.meg.
To find the word "chicken" with any letter case, press
F9. MegaDots shows you a window (a quick form) called Simple find, with
the prompt Enter text:. Type chicken with all
lowercase letters as your find string, and press
<Enter>. Your cursor will move forward from its current position to
the first occurrence of text that matches the find string. It should fall
on the first letter of "Chicken" in the title. Because you typed in all
lowercase letters, MegaDots did a case insensitive search and matched the
letters, whether lowercase or uppercase.
MegaDots has several ways of letting you know what happened in a search. If you have set Audio cues to Messages in the Editor Preferences, then "Found" or "No more matches" will appear on the status line. If you have set Audio cues to Sounds, you hear a pleasant tone or an unpleasant tone.
Now return to the beginning of the file with
Control-Home. Press F9 again. Since MegaDots always gives you the option
of using your last find string, "CHICKEN" appears again. You can begin
typing new text, or edit the text that is there. Press Delete to delete
the lowercase c and type in an uppercase C. When you press <Enter>
to accept Chicken, the cursor will move past "CHICKEN" in the
title to the paragraph starting, "Here's Huck Finn ....". Because you used
an uppercase letter in your find string, MegaDots did a case sensitive
search.
Now press Control-N. Your cursor will move to the next occurrence of "Chicken." If you keep pressing Control-N, your cursor keeps moving to the next occurrence of "chicken." Then press Control-End to move to the end of the document and then Control-L for the Last occurrence. The cursor moves backwards to the last occurrence of "chicken." If you keep pressing Control-L, the cursor keeps moving backwards to the last occurrence of "chicken." After doing this several times, keep pressing Control-N to move forward again. When your cursor is at the final occurrence of "chicken," the message is "No more matchs." This means that the word "chicken" does not occur after your current location.
Now let's do a backward search. Move to the end of the file with Control-End, and press Shift-F9. This time type "it was" <Enter> in lowercase letters. Your cursor will move to "It was" at the beginning of a sentence. You will soon learn how to search for "it was" with all lowercase letters using Complex find.
If you need to repeat a search that you've previously
done, you can use MegaDots' search history shortcut. After pressing F9 or
Shift-F9, press F2 at the Enter text: prompt. You will get a
list of the last 10 search text strings you have used in MegaDots, with
the most recent one at the top. You can move around this list as in any
other MegaDots list, either with the cursor keys or with incremental
search. When you find the search string that you want, press <Enter>
to do that search.
The MegaDots replace feature lets you change the text that you've found into a replacement string. The Control-G Global replace command does this replacement throughout all or part of your document: from the match found last to the end of the document, or to the block anchor if block marking or hold block marking is on. The Control-Y "Yes, replace this one" command replaces the text you just found and moves the cursor to the next match of the find string.
Let's pretend to be an over anxious editor who does
not want any sentence to begin with the word "Because." Press Control-Home
to move to the beginning of the document. Now, to find the word "Because"
with capital B, press F9, type Because <Enter>. Your
cursor will land on the first sentence beginning with "Because." Now press
Control-G for Global replace. The Simple replace quick form will prompt
Enter text:. Type It's because <Enter>.
MegaDots will put the message "5 replacements" on the status line.
"Because" with capital B occurred five times in this document, and both
occurrences have been changed to "It's because."
Now return to the beginning of the file with
Control-Home. We want to change some occurrences of "chicken" into "fine
chicken." Press F9 again, and type chicken <Enter>. To
move forward several occurrences, press Control-N several times. When you
come to an occurrence you want to change, press Control-Y. The Simple
replace quick form prompts Enter text:. When you type
fine chicken <Enter>, MegaDots makes the change and
moves the cursor to the next "chicken." Press Control-N to move to the
next "chicken" without any changes. Keep pressing Control-Y and Control-N
as much as you like in order to get used to using Simple replace.
Now, press Control-End to move to the end of the document and then press Control-Y. Since you are at the end of the document, you might expect MegaDots to say "no more matches." Instead it changes the last "warn't" found and moves to the next one. Similarly, press Control-End and Control-G. MegaDots moves the cursor to the last "chicken" found and changes "chicken" from there to the end of the file.
Since Control-Y and Control-G use the location of the last match rather than the current cursor position, you can move around freely as you edit, without losing your place for making replacements. If you have moved to another part of the document and want to make a replacement after the cursor position, just press Control-N first to move to the next match after the cursor, and then press Control-Y or Control-G to replace.
As a shortcut, you can specify a global replacement
string along with the find string. To do this, use a double backslash
(\\) to separate the find string from the replace string. For
example, you can type F9 hello\\goodbye <Enter> to
immediately change every occurrence of hello with goodbye.
When you have a block marked, the find and replace commands behave differently. When you begin marking a block with Control-X and issue a find command, the cursor will move to the next occurrence of your search string, and the block will follow. However, when you begin holding a block with Shift-Control-X and issue a find command, MegaDots will search only the text inside the block. When you use global replace with block marking or holding on, MegaDots does the replacements between the block anchor and the last item found.
A MegaDots rules file is a special MegaDots file which automatically instructs MegaDots to perform a set of find and replace operations specified in the file. Using rules files can greatly automate many text processing operations. When you invoke a rules file, it acts on your entire document, or on your marked block if there is one.
Rules files always have the file extension
.MDR. To invoke a Rules File, press Alt-F9 and type the name
of the file without the .MDR extension. MegaDots looks for
the rules file in your MegaDots program directory or your current
directory.
We have supplied a number of very useful rules files in your MegaDots program directory. They include:
CHARS.MDR - counts characters in your
document or marked block.
WORDS.MDR - counts words in your document or
marked block.
LOWER.MDR - changes uppercase letters to
lowercase.
UPPER.MDR - changes lowercase letters to
uppercase.
NOBREAK.MDR - gets rid of forced page breaks.
OUTLINE.MDR - when an outline has all entries
marked as outline level 1, this assigns hierarchy levels to the entries
based on the kind of opening label (uppercase Roman numerals, uppercase
letters, Arabic numbers, ...).
MENU.MDR - cleans up optically
scanned restaurant menu files (changes styles, inserts guide dots before
prices, and more).
There may also be some others. Check for files
with the .MDR extension in your MegaDots program directory.
As an example, suppose you accidentally had the caps
lock on. To change uppercase letters to lowercase in the affected text,
mark the text as a block, press Alt-F9, and answer the Enter
name: prompt with LOWER. That's all there is to it. If
you'd like to create your own rules file, first read the next section on
complex find and replace, then open a new MegaDots file, and enter your
complex find/replace strings, one per line. Then save your rules file with
a .MDR extension. Now press Alt-F9, and enter the name of
your rules file. Voila! Feel free to look at any of the included rules
files with the MegaDots editor. This can help you to learn how to write
your own rules files.
Complex find and replace is a very powerful tool for processing text. The Complex find and replace commands let you accomplish some tasks which you cannot do as efficiently or at all with the Simple commands. We use the word "complex" because these commands can accomplish complex tasks, not because they are hard to use.
Here are some important uses of Complex find and replace:
Using Complex find and replace is very similar to using simple find and replace. To begin a Complex find, you press Control-F9 to search forward or Control-Shift-F9 to search backward. Control-N, Control-L, Control-G, and Control-Y work as in Simple find and replace.
The only difference is in how you specify the text to find and the replacement text. In complex find and replace, you use a number of special characters to write expressions which can be as complex as small computer programs.
As described above, using the Simple find command with
all the letters lowercase gives a case insensitive search, ignoring letter
case. To find the text with only lowercase letters, use Complex find. At
the Enter text: prompt in the Complex find quick form, type a
quotation mark followed by the exact text. If the text includes a
quotation mark, use two quotation marks in its place. If you use Complex
replace, fill in the Complex replace quick form with a quotation mark
followed by the replacement text. Again, if a quotation mark is part of
the replacement text, use two quotation marks in its place.
Here is an example of replacing "he says" with "he
said" in huck.meg. Press Control-Home and Control-F9. Enter
the text "he says, including the opening quotation mark. Then
press Control-G. Enter the text "he said, including the
opening quotation mark. MegaDots reports 4 replacements. If you had done
this global replace with Simple find and replace, MegaDots would have done
7 replacements, with three of them putting lowercase h at the beginning of
a sentence.
This example is not terribly exciting. The power of Complex find and replace lies in many other uses.
You can build many factors, simple building blocks, into a Complex find string. Then MegaDots searches for text matching the first factor followed by text matching the second factor and so on. Before giving the list of all the different kinds of factors, here are a few examples.
If you do Simple find for the letters "he" in
huck.meg, you find them embedded in many other words. To find
just the word "he," press Control-F9. Give the find string
k'he'k. If you keep pressing Control-N, you find only "he" as
a word, with uppercase or lowercase h. In this find string, k stands for
any white space or literary punctuation character, and enclosing
he in single quotes does a case insensitive search on he.
Now let's move on to a more sophisticated example.
Copy the file intguide.meg (the MegaDots Interface Guide)
from the MegaDots directory into your working directory, and load it into
MegaDots. Suppose that you wish to find phone numbers in the file. Press
Control-F9 to ~(d/3~)bd/3~-d/4q, then press enter. This takes you to the
phone number for Enabling Technology under Bookmaker. Pressing Control-N
takes you to the phone number for Blazie Engineering under Braille Blazer.
If you keep pressing Control-N or Control-L, you will find various phone
numbers. Please don't send us the phone bill. In this find string, the
~( stands for an open parenthesis, the d/3
stands for 3 digits, the ~) stands for a close parenthesis,
b stands for a space, d/3 stands for 3 digits
again, ~- stands for a hyphen, d/4 stands for 4
digits, and q stands for a blank or punctuation. Then return
to the beginning of the file and do complex find for
wd/3~-d/3~-d/4q. This time you find phone numbers, with the
area code written differently. Finally, you can search for both forms of
phone number together with the find string
O~(d/3(~)b|~-)d/3~-d/4q. Pressing Control-N repeatedly shows
that we weren't very consistent.
Now it's time to learn what these enticing codes mean and how to use them. Here is the list of the different kinds of factors that you can build into a Complex find string. In this list, we use C1 and C2 to stand for any character; N1, and N2 to stand for any number; F1 and F2 to stand for any factors; and S1 and S2 to stand for any complex find strings.
"C1C2 ..." (characters enclosed between
quotation marks) - find these characters exactly. To include a quotation
mark in the text, use two quotation marks. You can leave out the closing
quotation mark at the end of the find string.
'C1C2 ...' (characters enclosed between single
quote marks) - find these characters EXACTLY, except possibly for letter
case. To include an apostrophe in the text, use two apostrophes. You can
leave out the closing apostrophe at the end of the find string.
~C1 - find this character exactly.
~C1-~C2 - find character which is between C1
and C2 in standard ASCII order.
#N1 - character with ASCII number N1
(decimal).
#N1-N2 - character with ASCII number between
N1 and N2 (decimal).
Eg - end of paragraph (<Enter>; the
E stands for End of).
El - forced end of line (Alt-<Enter>).
Ec - soft carriage return (Ec for end of
carriage).
Sa - forced apostrophe (Control-A; the S
stands for Special character). You can also press Control-A with quotation
mark, apostrophe, or tilde, or in Simple find.
Sh - unbreakable hyphen
(Control-U). You can also press Control-U with quotation mark, apostrophe,
or tilde, or in Simple find.
Sq - forced single quote (Control-Q). You can
also press Control-Q with quotation mark, apostrophe, or tilde, or in
Simple find.
Ss - hard space (Control-B). You can also
press Control-B with quotation mark, apostrophe, or tilde, or in Simple
find.
St - tab character.
#[ - the opening symbol in a markup command.
]# - the closing symbol in a markup command.
a - alphanumeric character (matches any
digit or letter).
d - digit (matches any digit).
l - letter (matches with any letter, uppercase
or lowercase).
s - small letter (matches with any lowercase
letter).
u - uppercase letter (matches with any
uppercase letter).
v - vowel (matches with any vowel).
Rl - Roman numeral letter (matches with
lowercase or uppercase i, v, x, l, or c).
Rs - Roman numeral small letter (matches with
lowercase i, v, x, l, or c).
Ru - Roman numeral uppercase letter (matches
with uppercase I, V, X, L, or C).
b - blank (matches with space or soft line
break).
w - white space character (matches with space,
tab, end of paragraph, or end of line, or hard space).
W - one or more white space characters (as
described above).
j - just literary punctuation (matches with
.,:;-'"?/()[]{}<>).
k - just literary punctuation or white space
character (matches with any literary punctuation character or any white
space character).
p - punctuation (matches with any punctuation
character).
q - punctuation or white space (matches with
any punctuation character or any white space character).
? (question mark) - one wildcard character
(matches any character)
* (asterisk) - wildcard string
(matches any number of characters, possibly zero characters).
(S1) (parentheses) - grouping, makes
string S1 a factor.
{S1} (braces, may be just {} with
nothing inside) - left brace marks position for the cursor when a match is
found; if a replacement is done, replace only the text matching S1.
OF1 - factor F1 is optional.
XF1 - in matching F1, use the exact text,
including invisible characters (such as markup).
F1/N1-N2 (slash followed by number N1, hyphen,
number N2) - factor F1 occurring some number of times with the number at
least N1 and not more than N2.
F1/N1- (slash followed by number N1, hyphen) -
factor F1 occurring N1 or more times
F1/N1 (slash followed by number N1) - factor
F1 occurring exactly N1 times.
^F1 (caret F1, with F1 a factor matching one
character) - one character not matching F1. See Example 8.
^N1-N2F1 (caret followed by number N1, hyphen,
number N2) - text with length between N1 and N2 not containing anything
matching the factor F1.
^N1F1 (caret followed by number N1) - text of
length exactly N1 not containing anything matching the factor F1.
^N1-F1 (caret followed by number N1, hyphen) -
text of length at least N1 not containing anything matching the factor F1.
F1&F2 (ampersand) - finds text matching
both factors F1 and F2. See Example 8.
S1|S2 (not a factor) - finds text matching
either S1 or S2. See Example 10.
When a complex find operation does find a string in your text, it puts your cursor at the beginning of the string, unless you used braces in the find string. If you used braces, it puts your cursor at the beginning of the string in your text which matches the part of the find string after the left brace.
qd/5q - 5-digit number. (You are
looking for zip codes.)
uus - two uppercase letters followed by a
lowercase letter. (Sometimes you press the Shift key down to capitalize
the first letter of a word but accidentally capitalize some additional
letters. This searches for errors of this kind.)
ww - two white space characters in a row.
(You want to avoid having two spaces, a space at the end or beginning of a
paragraph, etc.)
Eg{}'birds - the word "birds" at the
beginning of a paragraph. When this is found, the braces place the cursor
on the letter b instead of the end of paragraph symbol.
#[#35]# - inkprint page
indicator for page 35. (In transcribing inkprint page 35, you left out
some text and want to add it.)
#["#" - any inkprint page indicator. (You
want to make sure that all the inkprint pages are correctly marked with
the inkprint page indicator markup.)
l/12 - finds any word with at least twelve
letters. (Sometimes you jam words together by accident. Searching for long
words helps you find these errors.)
k{}(l&^'e')/11-k - a word of at least
10 letters not containing the letter e. (You are playing a word game. The
words qualifying in this chapter are "unconditionally," "punctuation," and
"translation.") The braces make the cursor land on the first letter and
not on the white space or punctuation before it.
'word'Ok'perfect' - case insensitive search
for the name WordPerfect, with or without a white space or punctuation
character in the middle. (You are reading an article about word processors
and want to skim for all the parts about WordPerfect. You know they were
inconsistent about how they wrote the name, and you want to find all the
possible spellings.)
"Leno"|"Letterman" - searches for the name
Leno or Letterman. (You want to search for two things at once, making only
one pass through your document.)
You can also test variables in a find string. There are five built-in variables you can test: style, group (the style group), level (the level in a hierarchical style), trans (the type of translation), and emph (the kind of emphasis). When you test a variable, enclose the name inside of brackets. The bracketed name is followed by a comparison operator followed by either a factor or a number value.
The comparison operators are:
= (equals) - tests if the variable equals
the value.
.= (period, equals) - tests if the value of
the variable begins with the specified string value (allows you to write
just the first few letters of the string value you want).
^= (not equal to) - tests if the value of the
variable is not equal to the specified value.
^.= (caret, period, equals) - tests if the
value of the variable does not begin with the specified string value.
<, <=, >,
or >= (less than, less than or equal to, greater than, or
greater than or equal to) - comparison only with specified number value.
Here are some examples of using variables:
Eg{}[style]="Body text"
- finds the beginning of any Body text paragraph. The Eg matches with the
end of paragraph marker. The empty braces place the cursor on the first
character of the paragraph, instead of the marker for the end of the
previous paragraph, and they say you do not want to delete any text if you
do some replacing.
Eg{}[style]='outline' [level]=3 - finds the
beginning of any paragraph that is at the third hierarchy level in an
outline.
Eg{}[group]="H" - finds the beginning of
any paragraph which is a heading (style in the Heading style group).
Eg{}[style].='bod' - finds the beginning of
any paragraph whose style name begins with the letters 'bod'
(case-insensitive). Since the only style name which begins with 'bod' is
Body text, this finds the beginning of body text paragraphs. Using the
.= comparison operator is a shortcut, allowing you to write
just part of the name.
Eg{}[style].=^3'bod' - finds the beginning
of any paragraph which does not have the Body text style. Literally, this
looks finds the beginning of any paragraph whose style name begins with
three characters not containing the letters "bod."
Eg{}[trans]^='c' - finds any paragraph not
beginning with CBC translation. (You have made a list where each paragraph
should start with an example in CBC. You use this search to find any items
where you accidentally left out the CBC markup.)
X'new page:'[group]='z' (must use Show
markup display) - finds forced page breaks (inkprint or braille). These
special paragraphs are in the "Section info" style (the only style in the
Z style group).
As with Simple find, after doing a complex find you can press Control-Y for one replacement or Control-G for doing a replacement globally throughout all or part of the document. MegaDots prompts you for the complex replace string. To exactly specify characters in the replace string, enclose them in double quotes. As in the complex find string, there are also some special codes for use in the replace string which are not enclosed in quotes:
"C1C2 ..." (characters enclosed between
quotation marks) - these characters exactly. To include a quotation mark
in the text, use two quotation marks. You can leave out the closing
quotation mark at the end of the find string.
~C1 - this character exactly.
#N1 - character with ASCII number N1
(decimal).
Eg - end of paragraph (<Enter>; the E
stands for end of).
El - forced end of line
(Alt-<Enter>).
Sa - forced apostrophe (Control-A; the S
stands for Special character). You can also press Control-A with quotation
mark or tilde, or in Simple replace.
Sh - unbreakable hyphen (Control-U). You can
also press Control-U with quotation mark or tilde, or in Simple replace.
Sq - forced single quote (Control-Q). You can
also press Control-Q with quotation mark or tilde, or in Simple replace.
Ss - hard space (Control-B). You can also
press Control-B with quotation mark apostrophe, or tilde, or in Simple
replace.
St - tab character.
#[ - the opening symbol in a markup command.
]# - the closing symbol in a markup command.
c - copy of the deleted text.
s - copy of the deleted text with all letters
made lowercase (s for small).
u - copy of the deleted text with all letters
made uppercase.
To set variables, use the variable name inside of
brackets followed by a colon, and then specify the value. The value you
specify may be a string inside of double quotes or a number. For example,
the replace string [style]:"Body text" sets the style to Body
text. The replace string [level]:2 sets the hierarchy level
to 2.
When you are performing either simple find (F9) or
complex find (Control-F9), you can specify a replace string right there
for global replace. To do this, use a double backslash (\\)
to separate the find string from the replace string. For example, you can
type Control-F9 'david'\\"David" to immediately perform this
global replace.
1. Suppose you have optically scanned a glossary, and
you want to use the italicized entries as guide text (guide words on the
bottom line). Press F2 and create a sample document called
complex.meg. Type a few paragraphs containing a word, phrase,
or name in italics followed by its definition. If your display is WYSIWYG,
press Alt-W to switch to Format markup. Here is how to change the italics
markup to guide text markup. Press Control-F9 and give the find string
#["Ei"]#. The #[ is for arrow beginning a
markup command. The O~\ is for an optional backslash. The
"Ei" is for uppercase E, lowercase i. The ]# is
for the arrow ending a markup command. Finally, the braces mean that only
the letters E, i will be deleted. When you press <Enter>, your
cursor moves to the start italics markup. When you press Control-N, it
moves to the end italics markup. Press Control-L to return to the first
occurrence, and press Control-G. For the replace string, enter
"Eg". If you have typed three Ei start
italics markup has changed to the Eg start guide text markup
and the \Ei end italics markup has changed to the
\Eg end guide text markup.
2. Sometimes documents brought into MegaDots from
optical scanning systems have extra paragraph breaks. (Note: If you really
have this problem with a file imported as ASCII Document, first try
importing it again as ASCII Quick.) Usually a paragraph break followed by
a lowercase letter should really be a space. Type some more text which is
broken up by unwanted paragraph breaks. Move to the beginning of this
text. Press Control-F9 and enter the find string {Eg}s. The
Eg stands for end of paragraph, the braces around it mean
that only the end of paragraph will be deleted, and the s
stands for any lowercase letter. Your cursor lands on the first end of
paragraph followed by a lowercase letter. Now press Control-G. For the
replace string enter " ". Any end of paragraph followed by a lowercase
letter changes to a space. The braces prevent the lowercase letter from
being deleted in this replacement.
3. You have an imported document with several
different levels of headings. You want the first heading marked as Heading
level 1 and the others marked as Heading level 2. The find string is
Eg{}[style].='hea'. The replace string is
[style]:"Heading level 2".
4. To change all uppercase letters to lowercase, the
find string is u and the replace string is s.
See the section below about the rules files LOWER.MDR and
UPPER.MDR.
5. Now suppose you have an address list, where each
paragraph contains all the items for one person, with semicolons between
the items. You want to change the first semicolon in each paragraph to a
colon. The find string is Eg*{~;}, and the replace string is
~:. If there is no end of paragraph before the first
paragraph, you need to change the first one by hand.
We have supplied several rules files as part of the MegaDots package. But you can write your own rules files to automate your own common text processing tasks.
A rules file contains a list of instructions, or rules, each specifying a find and replace operation. When you invoke the rules file with Alt-F9, MegaDots performs all of these find and replace operations on your entire document, or on the marked block if there is one. Even if a rules file contains only one rule, saving it in a file means you don't have to come up with the find and replace strings each time you need them.
You already know almost everything you need to write a
rules file. You can create a rules file in whatever file format you want,
but we recommend writing them as MegaDots files. Put any rules file in
your MegaDots program directory or in the current directory when you use
it. Put each replacement rule in a new paragraph. Each rule, written as a
Complex replace operation, contains the Complex find string, then two
backslashes, and then the Complex replace string. In particular, to
exactly specify the characters to find or to insert, you must enclose them
between quotation marks. You can also include comment paragraphs in a
The one remaining kind of paragraph in a rules file contains just two backslashes. It changes the way that MegaDots works through your document as it makes the specified changes. Ordinarily, MegaDots "stays on" the first character of your document and applies all the rules listed, then moves to the second character of the document and applies all the rules, and so on until it gets to the last character in the document. But sometimes we want MegaDots to apply one group of rules on the whole document and then go back to the beginning of the document to apply the next group of rules. A paragraph with just two backslashes ends one group of rules and starts the next group.
Examining the rules files supplied with MegaDots is a
good way to learn how to write your own rules files. First let's examine
the rules file CHARS.MDR. It counts the characters in your
document but does not make any changes. The only rule is
?{}\\ with nothing after the two backslashes. ?
stands for any character. The empty braces say to insert the replacement
text after the character without deleting anything. Since the replacement
text is nothing at all, no change is made. Since this happens for every
character in your file, the reported number of replacements is the number
of characters in your file. Use this rules file with WYSIWYG on, so that
it does not count the characters in "section info" paragraphs, like those
forcing a new page.
The rules file WORDS.MDR counts the words
in your document in a similar way.
The rules file LOWER.MDR changes all
uppercase letters to lowercase, including accented letters. This is
especially useful if you had the caps lock on unintentionally. Mark the
affected text as a block, press Alt-F9, and specify the rules file
lower. Let's examine this file. The first rule
u\\s changes unaccented uppercase letters to lowercase.
u finds any unaccented uppercase letter. When a replacement
is made, the uppercase letter is deleted. But the s in the
replace string puts in a lowercase copy of the deleted text, in this case
the lowercase letter.
The second rule is X(#128-#206u)\\s. The
first rule does not find accented letters, represented internally as a
special character followed by the underlying letter. You can see the
internal representation by switching Markup view to All markup (press
Control-Z M A). The letter in this representation is "invisible," so that
you do not find an accented e when you are looking for a regular e. The
X in the second rule tells MegaDots to look at all the text,
no matter what. The X applies to everything inside the parentheses,
because the parentheses make that a factor. The #128-#206
covers all the possible special characters used to introduce accented
letters. The find string finds one of these special characters followed by
a letter. When this is found, it is deleted. But the replacement string
s inserts a lowercase copy of the deleted text.
The rules file UPPER.MDR is similar,
changing all lowercase letters to uppercase.
OUTLINE.MDR works on an outline where
everything is marked as hierarchy level 1. It changes the levels, based on
the nature of the label for that entry.
MENU.MDR works on scanned
menus. It does some cleanup, inserts guide dots before prices, and assigns
styles appropriate in a menu.
If you want clarification on these rules files or any others supplied with MegaDots, read the comment lines, which start with two percent signs.