Engineering Requirements Management

Engineering Requirements Management

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

 View Only
  • 1.  String operations in DXL

    Posted Thu February 18, 2021 08:10 AM

    Hi everyone, many thanks for your help in advance.

    I am using analysis wizard in order to obtain values of an attribute coming from inlinks.

    For this I am using the automatically generated code below.

    My question is, I want to merge the values without duplications, however this codes gives me all the values with including duplications.

    If I may explain a little bir more;

    Attributes has means of verification codes like 0, 1, 2 ...

    If 2 or inlinks have the same attributes then I get a output like 1,1,2,2 .. but I want to see an output of 1, 2 so deletion of duplicates shall be completed in the code.

    // DXL generated by DOORS traceability wizard on 18 February 2021.

    // Wizard version 2.0, DOORS version 9.7.0.0

    pragma runLim, 0

    void showIn(Object o, int depth) {

    Link l

    LinkRef lr

    ModName_ otherMod = null

    Module linkMod = null

    ModuleVersion otherVersion = null

    Object othero

    Module mOther

    string disp = null

    string s = null

    string plain, plainDisp

    int plainTextLen

    int count

    bool doneOne = false

    Item linkModItem = itemFromID("50b5d9353461367b-000022ef")

    if (null linkModItem) {

    displayRich("\\pard " "<<Link module not found>>")

    } else if (type(linkModItem) != "Link") {

    displayRich("\\pard " "<<Invalid link module index for this database>>")

    } else {

    string linkModName = fullName(linkModItem)

    for lr in all(o<-linkModName) do {

    otherMod = module (sourceVersion lr)

    if (!null otherMod) {

    if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {

    load((sourceVersion lr),false)

    }

    }

    }

    for l in all(o<-linkModName) do {

    otherVersion = sourceVersion l

    otherMod = module(otherVersion)

    if (null otherMod || isDeleted otherMod) continue

    mOther = data(otherVersion)

    if (null mOther) {

    load(otherVersion,false)

    }

    othero = source l

    if (null othero) continue

    if (isDeleted othero) continue

    doneOne = true

    if (depth == 1) {

    s = probeRichAttr_(othero,"Means of Verification", false)

    if (s == "")

    displayRich("\\pard " " ")

    else

    displayRich("\\pard " s)

    }

    }

    }

    }

    showIn(obj,1)





    #Sustainability
    #Support
    #EngineeringRequirementsManagement
    #SupportMigration
    #DOORS


  • 2.  RE: String operations in DXL

    Posted Tue February 23, 2021 09:19 AM

    This product forum is intended for client to client collaboration.

    If you want to engage IBM Support, you should open a support case:

    https://www.ibm.com/mysupport/s/createrecord/NewCase





    #SupportMigration
    #Sustainability
    #DOORS
    #EngineeringRequirementsManagement
    #Support


  • 3.  RE: String operations in DXL

    Posted Wed March 24, 2021 06:14 PM

    I frequently have issues like what you described where multiple duplicate results are returned. This is how I remove duplicates...

    1. Put all returned values into one string with each value separated by a new line (\n)
    2. Write a function that sorts each \n separated line in the string in alphabetical order
    3. Write a function that parses each \n separated line in the alphabetically sorted string and remove any line in which the line is a duplicate of the previous line

    Assembled string in 1:

    kappa

    mu

    beta

    gamma

    mu

    mu

    alpha

    betas

    beta

    Sorted string in 2:

    alpha

    beta

    beta

    betas

    gamma

    kappa

    mu

    mu

    mu

    String with duplicates removed in 3:

    alpha

    beta

    betas

    gamma

    kappa

    mu





    #EngineeringRequirementsManagement
    #SupportMigration
    #Sustainability
    #Support
    #DOORS


  • 4.  RE: String operations in DXL

    Posted Thu March 25, 2021 09:08 AM

    Hi Richard, many thanks for your answer, is it possible for you to share the functions that you mentioned above post.





    #Support
    #SupportMigration
    #Sustainability
    #EngineeringRequirementsManagement
    #DOORS


  • 5.  RE: String operations in DXL

    Posted Thu March 25, 2021 11:28 PM

    Here is the code...


    /*                                        */

    /*--------------------------------------------------------------------------------*/

    /*                                        */

    /* Sorts a CR-LF delineated "toSort" string and returns the string sorted     */

    /* alphabetically. If parameter "ascendingOrder" is true, sorts in ascending   */

    /* order, otherwise sorts in descending order.                  */

    /*                                        */


    string alphaSort (string toSort, bool ascending) {

    string copyOfToSort = toSort

    string finishedString = ""

    string swapPlaces

    int crLfPosition, dummyLength

    int numLines = 1


    /* Count the number CR-LF's in the string to be sorted */

    for (findPlainText(copyOfToSort, "\n", crLfPosition, dummyLength, false)) {

    numLines++

    copyOfToSort = copyOfToSort[0:crLfPosition-1] copyOfToSort[crLfPosition+1:]

    }


    /* Parse the string elements into array elements */

    copyOfToSort = toSort


    string sortArray[numLines]

    for (i = 0 ; i < numLines ; i++) {

    findPlainText(copyOfToSort, "\n", crLfPosition, dummyLength, false)

    if (i < numLines-1) {

    sortArray[i] = copyOfToSort[0:crLfPosition-1]

    copyOfToSort = copyOfToSort[crLfPosition+1:]

    }

    else sortArray[i] = copyOfToSort

    }


    /* Sort the array elements in ascending or descending order */

    for (i = 0 ; i < numLines-1 ; i++) {

    for (j = i+1 ; j < numLines ; j++) {

    if (((upper(sortArray[i]) > upper(sortArray[j])) && ascending) || ((upper(sortArray[i]) < upper(sortArray[j])) && !ascending)) {

    swapPlaces = sortArray[i]

    sortArray[i] = sortArray[j]

    sortArray[j] = swapPlaces

    }

    }

    }


    /* Assemble finished string from sortArray, eliminating duplicates */

    finishedString = sortArray[0]

    for (i = 0 ; i < numLines-1 ; i++) {

    if (sortArray[i] != sortArray[i+1]) finishedString = finishedString "\n" sortArray[i+1]

    }

    if (finishedString[0:0] == "\n") finishedString = finishedString[1:]

    if (length(finishedString) > 1) {

    if (finishedString[length(finishedString)-1:length(finishedString)-1] == "\n") finishedString = finishedString[0:length(finishedString)-2]

    }

    return finishedString

    }

    //-----------------------------------------

    // Main routine

    string allMessages = ""

    string eachMessage

    // Each time "eachMessage" takes on a new value, put the following line...

    allMessages = allMessages "\n" eachMessage

    // When the messages have been assembled, do...

    allMessages = alphaSort (allMessages, true)





    #Support
    #DOORS
    #Sustainability
    #EngineeringRequirementsManagement
    #SupportMigration


  • 6.  RE: String operations in DXL

    Posted Tue March 30, 2021 04:47 PM

    An alternative would be to use Skip lists feature to have unique keys

    Skip sk = createString() put (sk, "a", "a") put (sk, "b", "b") put (sk, "a", "a") string s for s in sk do {print s " "} -> a b



    #Support
    #Sustainability
    #SupportMigration
    #EngineeringRequirementsManagement
    #DOORS


  • 7.  RE: String operations in DXL

    Posted Wed March 31, 2021 05:12 PM

    An alternative method is to compile your message string on the basis of whether or not the message is already contained in the output message.


    string allMessages = "\n"

    string eachMessage

    int strPos, strLen

    // Each time "eachMessage" takes on a new value, put the following line...

    if (!findPlainText(allMessages, "\n" eachMessage "\n", strPos, strLen, true)) allMessages = allMessages eachMessage "\n"

    // When the messages have been assembled, do...

    print allMessages





    #DOORS
    #Sustainability
    #EngineeringRequirementsManagement
    #Support
    #SupportMigration


  • 8.  RE: String operations in DXL

    Posted Thu April 15, 2021 01:35 PM