Search code examples
ibm-doors

Searching for text in module using dxl


How do you search for text in module using dxl script. Once found I want to highlight the object in which the text was found


Solution

  • The corresponding DXL Perm for highlighting is

    Declaration

    bool highlightText(Object, int start, int stop, int colIndex, bool isHeading)
    

    Operation

    Highlights text in the given module, in the given column from cursor position start to cursor position stop.

    Example

    //Highlights the first 10 characters of the current objects heading
    highlightText(current Object, 10, 20, 1, true)
    

    Note that only one object can be highlighted at one time. Look at chapter "Object searching" in the DXL manual for other perms you might need in this context.

    For searching I would suggest the perm contains

    Declaration

    int contains(Buffer b, char ch [,int offset])
    int contains(Buffer b, string word, int offset)
    

    Operation

    The first form returns the index at which the character ch appears in buffer b, starting from 0. If present, the value of offset controls where the search starts. For example, if offset is 1, the search starts from 2. If offset is not present, the search starts from 0. If ch does not appear after offset, the function returns -1. The second form returns the index at which string word appears in the buffer, starting from 0, provided the string is preceded by a non-alphanumeric character. The value of the mandatory offset argument controls where the search starts. If word does not appear after offset, the function returns -1.