Searching for next merge field

  • Greetings...:)

    In versions prior to 5, code similar to the following would find the next merge code field:

    Code
    with WPRichText1.Finder do begin
          Position := Pos;
          match_attr := [wmtIsInsertPoint];  // "category" to search for
          cmp_attr.style := [afsIsInsertPoint]; //  attribute within that category
          WildCard := '*';
    
    
          if(  Next( '*' ) ) then...


    Could you please give an example of how searching for the next merge code field is done in WPTools 5 (or point me at a demo program that has code that does it)?

    Thanks...:)

    diamond[/code]

    • Offizieller Beitrag

    Since mergefields are objects you can use the functions wich move the cirsor to objects. For example the procedures in WPRichText.TextObjects.

    But for your desire I suggest to use

    WPRichText.TextCursor.NextObjAtCP and test
    ObjType and the Mode

    Julian

  • Could you please provide a short snippet that would show how all this would work together?

    Two useful variations I can think of are:

    o one where you want to test if the cursor is presently over a merge field

    o a second situation where you want to find the next merge field in the document

    Seeing all this in action would make the new approach more clear. I didn't notice any examples of the Finder class in any of the Demos, and I'd like to see how the new Mode and ObjType would be used here.

    Thanks...:)

    diamond