Genii Weblog


Civility in critiquing the ideas of others is no vice. Rudeness in defending your own ideas is no virtue.


Tue 17 Jan 2006, 08:41 AM
Here are links to the first six of the customer inspired list of ways to Make Rich Text Your Business:
MRTYB #10 - Rich text comparisons with red-lining
MRTYB #9 - Manage doclinks, URL links and link hotspots
MRTYB #8 -  Build dynamic forms
MRTYB #7 - Work with images in rich text and in image resources
MRTYB #6 - Construct complex and elegant reports
MRTYB #5 - Build dynamic interfaces with layers

Layers are a bit exotic for a lot of people, so let's get down to a more common need, Search and Replace.  But of course, given that this is a Midas product, it is a Search and Replace far beyond any you may have seen. For #4...


#4) Search and Replace on steroids

Description
One of the most common editing activities is searching and replacing text, but searching and replacing rich text can be a bit more tricky.  Should everything you can see be searched and replaced, including the labels on buttons, the titles in sections, and the caption on graphics, or should only the "pure text" be searched?  What about the rich text you cannot see, such as action hotspots, URLs in URL links, hide formulas and that sort of thing?  In the Midas Rich Text LSX, we think you need the power to search and replace in all of these contexts, but the flexibility and control to pick and choose.  If you want to replace a fieldname used in hide-formulas, but nowhere else, you can do it.  If you want to change a server name hardcoded into URL links, you can do that.

In addition, sometimes you know the exact search string and the exact replacement string, but sometimes you only know a rough pattern.  For those times, the Midas Rich Text LSX will match simple wildcard patterns in your text and replace those with a specified string.

And beyond that, sometimes you don't know what the replacement string should be at all, but want a process to determine the string based on various factors, such as what the actual string found was in a wildcard pattern or the user who is doing the replacement.  In those cases, the Midas Rich Text LSX can trigger an event which will allow you full control over the replacement string based on the search string and whatever else you want.

History
In 1997, for Notes R4.1, the Midas Rich Text LSX was introduced, and in the original set of features was search and replace with wildcards and events on demand.  In 1998, the ability to search non-text strings was added, still for R4.1 and up.  It was not until 2002, with Notes/Domino 6.0, that IBM added even the simplest form of search and replace to its rich text classes, and even then without any of the specialized features Midas has.  Even in 2006, with Notes/Domino 7.0, there is no support for wildcards or pattern matching, no support for changes to anything other than pure text, and no ability to control the replacement based on events, formulas or scripts.

Oh yes, and speaking on search and replace on steroids, with that first release of Midas in 1997, we also released the LinkMatching method, which allows you to search for any string represented by a document in a view and replace it with a link hotspot back to the found document.  This was later enhanced, in 2003, to add the AppendMatching, InsertMatching, ReplaceMatching, KeywordMatching and PopupMatching methods, to further extend the idea of search and replace.

Comparison with standard Notes/Domino functionality
It was not until 2002, five years after Midas introduced pioneered search and replace technology in LotusScript, that with Notes/Domino 6.0 IBM added even the simplest form of search and replace to its rich text classes, and even then without any of the specialized features Midas has.  Even in 2006, with Notes/Domino 7.0, there is no support for wildcards or pattern matching, no support for changes to anything other than pure text, and no ability to control the replacement based on events, formulas or scripts.  Notes/Domino also still has nothing like the LinkMatching and other SmartRefs functionality.

Documentation
The documentation on search and replace technology is mostly found in the Midas Help database under the ReplaceText method, the UserReplaceText method (for events) and in the LinkMatching and other method descriptions.

On-line demo
Search & Replace:  Allows you to search for and replace simple words and phrases or wild card expressions, either with your own or with a standard content.

Sample Database
Jose's Keyword Replacement - Example shows how to replace keywords in a rich text field with rich text segments (images, stylized text, etc.) as would be used in a document assembly or mail merge type application.

Midas Editing - Example shows a variety of methods used to edit existing text, including search and replace with wildcards and dynamic link creation with links created in text and around graphics.

Replace URLs - This sample shows different ways to modify or replace URL's in URL hotspots both in rich text fields and in design elements such as pages and forms.
Sample Script Snippet
This snippet would replace every instance of the string LeadArbitrator with the string Leader in any hide-when formulas anywhere in the rich text.
Set rtitem = New GeniiRTItem
Call rtitem.ConnectBackend(doc.Handle, "Body")
If rtitem.IsConnected Then
   Call rtitem.Everything.ReplaceText("LeadArbitrator", "Leader", "HIDE_FORMULA");
   If rtitem.Modified Then rtitem.Save
End If
Weblog Posts on Search and Replace
Carrying Concealed (Mike Midas case file)

Copyright © 2006 Genii Software Ltd.