Engineering Requirements Management

Engineering Requirements Management

Come for answers, stay for best practices. All we're missing is you.

 View Only
Expand all | Collapse all

DOORS dxl script findPlainText comparison not working with data from a skip list.

  • 1.  DOORS dxl script findPlainText comparison not working with data from a skip list.

    Posted Mon October 12, 2020 04:08 PM

    I have a subroutine that I pass a string value from a skip list. That value is compared to objects in a Doors File. But the comparison does not work.

    string SW_VRC="Object Text"

    Module currMod = current Module

    Skip split (string s, string delim)

    {

    Skip skp = create

    int i = 0

    Regexp split = regexp "^(.*?)" delim "(.*)$"

    while (split s)

    {

    string temp_s = s[match 2]

    put(skp, i++, s[match1] "")

    s = temp_s

    }

    put(skp, i++, s "")

    return skp

    }

    string getInfo( string inStr)

    {

    int offsetFromFind, lengthFromFind

    string resultString = ""

    Object currObj

    for currObj in currMod do

    {

    if ( findPlainText( ( currObj.SW_VRC ""), inStr, offsetFromFind, lengthFromFind, false ) )

    {

    print currObj.SW_VRC " matches " inStr "\n";

    resultString = resultString "\n" currObj."SW_VRC ""

    }

    }

    return resultString

    }

    string modname = "a,b,cc,ccc,d,e,f"

    Skip newLst = split (modname,",")

    string inputInfo;

    find(newLst, 0, inputInfo)

    getInfo(inputInfo)

    Now this is a simplified version of what I am doing. But the findPlainText does not match anything. inputInfo is getting the correct string, I checked. The part that really kills me is if I hardcode in the parameter

    i.e. inStr = "21";

    It works like it's supposed to. Now I was assuming a string is a string. Is there a difference between a string from a skip list and a string that's quoted? Is there a hidden character? What am I missing? Any insight you could provide would be welcome.

    Thanks,

    DevM





    #Sustainability
    #EngineeringRequirementsManagement
    #DOORS
    #Support
    #SupportMigration


  • 2.  RE: DOORS dxl script findPlainText comparison not working with data from a skip list.
    Best Answer

    Posted Wed October 14, 2020 03:24 PM

    No there is no difference. Had to fix a couple errors but the following code worked as I expected. It matched every object with the object text containing the word in the first position of the script.

    string SW_VRC="Object Text" Module currMod = current Module Skip split (string s, string delim) { Skip skp = create int i = 0 Regexp split = regexp "^(.*?)" delim "(.*)$" while (split s) { string temp_s = s[match 2] put(skp, i++, s[match 1] "") s = temp_s } put(skp, i++, s "") return skp } string getInfo( string inStr) { int offsetFromFind, lengthFromFind string resultString = "" Object currObj for currObj in currMod do { if ( findPlainText( ( currObj.SW_VRC ""), inStr, offsetFromFind, lengthFromFind, false ) ) { //print currObj.SW_VRC " matches " inStr "\n"; resultString = resultString "\n" currObj.SW_VRC "" } } return resultString } string modname = "appendix,b,cc,ccc,d,e,f" Skip newLst = split (modname, ",") string inputInfo; find(newLst, 0, inputInfo) print getInfo(inputInfo)



    #SupportMigration
    #Support
    #Sustainability
    #EngineeringRequirementsManagement
    #DOORS


  • 3.  RE: DOORS dxl script findPlainText comparison not working with data from a skip list.
    Best Answer

    Posted Tue October 20, 2020 01:46 PM

    David,

       Thank you so much  for trying to help. I did figure out my problem though. It seems that when I put my input data on the command line I formatted it like this:

    "/MTA/CC/PWRSS, 21, 22"

    Now the script did a great job of parsing the commas (,) but it seems that for findPlainTest Twenty-one ("21")  and space Twenty-one (" 21"​) are two very different animals. I wrote a subroutine to remove leading and trailing spaces and it fixed the problem.


    Thank You for your help,

      DevM





    #DOORS
    #EngineeringRequirementsManagement
    #Sustainability
    #Support
    #SupportMigration