-------------------
Date: 11 Mar 92 11:11:43 PST
From: Doug Wyatt:PARC:xerox
Subject: Re: question (TiogaToWalnut)
In-reply-to: "weiser's message of Wed, 11 Mar 92 02:47:21 PST"
To: weiser
cc: wyatt, chauser, terry, atkinson, plass
Well, that was a puzzler, but I think I get it. The problem is with TiogaOps.NodeSearch: despite the claim of the comment in the interface, it depends in a subtle way on the state of the current primary selection! TiogaOps2Impl.NodeSearch calls TiogaOps2Impl.DoSearch, which calls TEditInputOpsImpl.CallWithLocks, which fails to call proc if SelectionRoot[pSel] is NIL. Saving a viewer kills the primary selection, and all your subsequent searches fail.
It's safer in general to stay away from TiogaOps and use lower-level Tioga interfaces. (This would be cleaner in Cedar10; in particular, I've overhauled the searching stuff.) Try something like this:
Node: TYPE ~ TextNode.Ref;
Location: TYPE ~ TextNode.Location;
Pattern:
TYPE ~ TreeFind.Finder;
CreatePattern:
PROC [target:
ROPE, word:
BOOL ←
FALSE]
RETURNS [Pattern] ~ {
RETURN [TreeFind.CreateFromRope[pattern: target, ignoreCase: TRUE, word: word]];
};
Search:
PROC [pat: Pattern, first, last: Node]
RETURNS [found:
BOOL, loc: Location] ~ {
[found: found, where: loc.node, at: loc.where] ←
TreeFind.Try[finder: pat, first: first, last: last];
};
pat1: Pattern ~ CreatePattern[target: "\r$$Date:$$"];
pat2: Pattern ~ CreatePattern[target: "\n$$Date:$$"];
pat3: Pattern ~ CreatePattern[target: "|$$Date:$$"];
pat4: Pattern ~ CreatePattern[target: "$$Date:$$", word: TRUE];
ExtractDate:
PUBLIC PROC [ref: Node]
RETURNS [date:
ROPE] ~ {
found1, found2, found3, found4: BOOL;
foundnode, end1, end2, end3, end4: Location;
errorloc: Location;
textWithDate, errorField: ROPE;
endOfDate: INT;
{
last: Node ~ TextNode.LastWithin[ref];
[found: found1, loc: end1] ← Search[pat1, ref, last];
[found: found2, loc: end2] ← Search[pat2, ref, last];
[found: found3, loc: end3] ← Search[pat3, ref, last];
[found: found4, loc: end4] ← Search[pat4, ref, last];
... etc. ...