Timing problem ?
Test, test, test...
In my script at the place where I find a string and replace it by a paragraph contens, it turns out that the very first operation is not performed.
I inserted an alert to find out whether the item can really be found - and voilà the function is OK.
Then I replace the alert by a Console command - and it still works.
Removing this line resuls in loosing the first find/replace.
What's going on here?
The following is just part of the function:
...
findParams = GetFindParams (findString); // Get the find parameters for finding string, case sensitive
//FA_errno = Constants.FE_Success; // errno global, to be used to track the progress of the find and replace
tr = targetDoc.Find(tr.beg, findParams); // and do an initial find to get started.
// find and replace loop as long as we keep finding
Console ("textrange selected ?");
while(FA_errno === Constants.FE_Success && loopCounter++ < 2*loopMax) {
targetDoc.TextSelection = tr; // set up the text range to clear the original text
targetDoc.Clear(0); // clear it
app.ActiveDoc = sourceDoc; // switch to sourceDoc
sourceDoc.TextSelection = trReplace; // to be able to get the replacement text
sourceDoc.Copy(0);
app.ActiveDoc = targetDoc; // switch to targetDoc
targetDoc.Paste(0); // and paste the replacement text
ReApplyFontAndSize (targetDoc, tr); // re-apply the current para format...

