CorelPerfect StrTransform give unexpected result.

WordPerfect X9, Version 19.0.0.325, on Windows 10 Pro, build 17134.523.

Using StrTransform, I get a result I do not expect. Does this result seem reasonable to others?

Scroll down past the short program to see the output which seems incorrect to me.

This program is not the original application. I've stripped away about 3,500 lines of code to build this test.

Also, the input normally comes from a WordPerfect document which has hard returns in the text. I get them in the macro using ?SelectedText. In general I don't know if there will be a hard return or not, and needing specific extra code to try to handle it seems unreasonable. And I think StrTransform is broken.

---------------------------------------------------------------------------------------------------------------

Application (WordPerfect; "WordPerfect"; Default!; "EN")

    crlf    := NToC (HardReturn!)
    crlf2 := crlf + crlf
    x1    := crlf + "XX"
    x2    := "XX"

    text1 := x1 + "TestString"
    y1 := StrTransform (text1; x1; "#"; Strings!)        // replace HardReturn! + "XX" with "#"

    text2 := x2 + "TestString"
    y2 := StrTransform (text2; x2; "#"; Strings!)        // replace "XX" with "#"

    Prompt ("debug"; "|" + text1 + "|" + x1 +  "|" + y1 + "|" + crlf2 + "|" + text2 + "|" + x2 + "|" + y2 + "|")
    Pause ()

Quit

---------------------------------------------------------------------------------------------------------------

I separate strings with vertical bars, and examples with a blank line.

First example:

The first string (input to StrTransform) between the vertical bars displays as I expect: a hard return followed by "XXTestString".

The second string is the 'replace this' string: hard return + "XX".

The third string (output from StrTransform) is incorrect. StrTransform has not replaced the hard return, and has removed the "T" which should be between the "#" and "estString".

Second example:

The first string (input to StrTransform) displays as expected: it does not contain a hard return, only "XXTestString".

The second string is the 'replace this' string: "XX".

The third string (output from StrTransform) displays as expected.

Is my expectation (the result I expect in example 1: "XXTestString") unreasonable?

- Steve