WP Tools: 5.48.5, Delphi 5, Windows XP. Two WPT files sent by e-mail to support_at_wptools.de. (My apology for a long post but there is no easy way to describe this problem clearly.)
I am developing an application that represents about 60 items in a WP document to define structure of a medical progress note.
Each item in the progress note is represented by a Heading bookmark and a BodyText bookmark (e.g., "Examination of Heart" will have a heading and details (body text) of physician's findings). Thus, there are ~ 120 bookmarks in the document.
All bookmarks are created into a blank editor when user starts a new note (editor has already been initialized with: RTFMemo.CheckHasBody; par := RTFMemo.FirstPar;). These are placed in pairs in the editor in a For...Loop using BookmarkInput() (Heading_XYZ then BodyText_XYZ) so they are always in that order and in a pair.
Bookmarks are NOT added, deleted or moved once they are placed in the WP editor. Until filled by user action, bookmarks remain blank (i.e., contain no text between start and end tags.)
Application provides interface to add predefined text fragments into bookmarks (either plain text or WP formatted text). Text is placed inside the bookmark by setting CPPosition inside the bookmark and using either InputString() (if it is plain text) or using SelectionAsString (if it is WPT formatted text).
Of course, user can also directly type into the WP Editor. Idea is simple: bookmarks provide a structure and user action adds text.
Basically, this works well except when it doesn't <g> as noted in this post.
Problem described below occurs FREQUENTLY AND UNEXPECTEDLY. So far, I have not been able to identify a sequence of steps that will consistently reproduce the problem .
I am sending TWO files as e-mail attachment - one where process [mostly] worked as expected and 2nd when similar steps deleted/changed bookmarks tags to invalid tags (e.g. opening tag [ch=2] is changed to [ch=1] ). Please see snippets from these files below.
Problem: Inserting text into a bookmark sometimes:
1. Deletes opening bookmark tags and changes order of bookmarks. These tags seem to be replaced by [ch=1].
2. Order of bookmarks is changed.
One look at file: "Bookmarks_When_Error.WPT" will show you the nature of this error.
The 2nd file, "Bookmarks_When_Good.WPT" shows output and bookmarks when process works correctly. It was created with SIMILAR STEPS. I included this to show how Bookmarks look when this problem does not appear in display (Even this file shows some [ch=1] instead of [ch=2]).
This may help you debug: Normally, HD-xyz (heading bookmark) always comes before BT-xyz (BodyText bookmark) as follows (from "Good" file). Note that order of first two pairs is correct but then bookmark order is reversed (BT-xyz has moved before HD-xyz):
<begin Tag=259 style="Name:'HD-Chest';" wpsty=[[Type:3;Mode:3;Name:"HD-Chest";]] ch=2/><end Tag=259 ch=3/><begin Tag=260 style="Name:'BT-Chest';" wpsty=[[Type:3;Mode:3;Name:"BT-Chest";]] ch=2/><end Tag=260 ch=3/><begin Tag=261 style="Name:'HD-Breast';" wpsty=[[Type:3;Mode:3;Name:"HD-Breast";]] ch=2/><end Tag=261 ch=3/><begin Tag=262 style="Name:'BT-Breast';" wpsty=[[Type:3;Mode:3;Name:"BT-Breast";]] ch=2/><end Tag=262 ch=3/><begin Tag=263 style="Name:'BT-Followup Visit';" wpsty=[[Type:3;Mode:3;Name:"BT-Followup Visit";]] ch=1/><begin Tag=264 style="Name:'HD-Followup Visit';" wpsty=[[Type:3;Mode:3;Name:"HD-Followup Visit";]] ch=1/><begin Tag=265 style="Name:'BT-Imaging Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"BT-Imaging Orders for Next Visit";]] ch=1/><begin Tag=266 style="Name:'HD-Imaging Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"HD-Imaging Orders for Next Visit";]] ch=1/><begin Tag=267 style="Name:'BT-Lab Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"BT-Lab Orders for Next Visit";]] ch=1/><begin Tag=268 style="Name:'HD-Lab Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"HD-Lab Orders for Next Visit";]] ch=1/>
But, in "Error" file (Below), and a few in "Good" file (above):
1. "Order" of bookmarks has changed. Now, for many items, BodyText (BT-xyz) shows up BEFORE heading bookmark (HD-xyz).
2. Opening Tag (ch=2) and Closing Tag (ch=3) have been replaced with ch=1 for many bookmarks.
3. There are some (ch=1) tags in "Good" file too. These may represent an error but since I did not fill these bookmarks with text, I did not notice them in interactive mode (only noticed these while examing WPT file).
<begin Tag=263 style="Name:'BT-Followup Visit';" wpsty=[[Type:3;Mode:3;Name:"BT-Followup Visit";]] ch=1/>
<begin Tag=264 style="Name:'HD-Followup Visit';" wpsty=[[Type:3;Mode:3;Name:"HD-Followup Visit";]] ch=1/>
<begin Tag=265 style="Name:'BT-Imaging Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"BT-Imaging Orders for Next Visit";]] ch=1/>
<begin Tag=266 style="Name:'HD-Imaging Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"HD-Imaging Orders for Next Visit";]] ch=1/>
<begin Tag=267 style="Name:'BT-Lab Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"BT-Lab Orders for Next Visit";]] ch=1/>
<begin Tag=268 style="Name:'HD-Lab Orders for Next Visit';" wpsty=[[Type:3;Mode:3;Name:"HD-Lab Orders for Next Visit";]] ch=1/>
and at the end of file, many of the following:
<end Tag=265 ch=1/>
<end Tag=266 ch=1/>
<end Tag=267 ch=1/>
---------<snip>-------- But look at the very last one below---
<end Tag=335 ch=1/>
<end Tag=336 ch=1/>
<end Tag=337 ch=1/>
<end Tag=338 ch=1/>
<end Tag=263 ch=3/>
Alles anzeigen
Needless to say, this is a Show-Stopper. I have full faith you will take care of this ASAP.
Thanks in advance.
JayM