[Date Prev][Date Next][Subject Prev][Subject Next][ Date Index][ Subject Index]

Single-character search



Here's a slightly more elaborate search routine that lets you search by simply
typing characters -- each character is appended to the search argument and the
search is re-run.
There are a couple of extras here:
Edit the search string by backspacing.
Repeat the search on the current string by pressing the down arrow.
Reverse the direction of the search by using the up and down arrows.
Jump to the first instance of the current search string in the file.
Toggle case-sensitivity on by pressing the Shift key by itself at the start of
the search.
Search argument is saved and presented next time. Also appears in Menus search
routine (Save/Get 1840).

Code could be added to operate on the target string: delete, copy to
clipboard, etc. But that could defeat the search strategy: get to the target
string with the fewest keystrokes. In most documents, you'll find your target
within 4 to 5 keystrokes, but the search argument (of course) will contain
only those keystrokes.

The program is heavily annotated. I'm sure there are some more efficient ways
of doing some of the things in it. The parsing routine for paring off the
rightmost character was picked up from code in the XyWrite DLG file, for
instance, and it could probably be made more efficient.

You'll probably want to load this onto a key and/or stuff it into a U2 file.

Tim Baehr

XyWrite XPL program