Engineering Requirements Management

 View Only
  • 1.  Looping over inlinks issue

    Posted Thu February 02, 2023 12:33 PM
    Hello all, 
    I'm trying to loop over all the inliks of a given module, but nothing is outputed although the inlinks exist.

    here is my script

    Link inLink
    Object obj
    for obj in current Module do {
    for inLink in obj<-"*" do {
    print("sh")
    }
    }

    Thank you

    ------------------------------
    Khalid
    ------------------------------

    #Sustainability
    #EngineeringRequirementsManagement


  • 2.  RE: Looping over inlinks issue
    Best Answer

    Posted Fri February 03, 2023 03:45 AM
    Hello Khalid,
    You must use the type "LinkRef" to loop over the inlinks, like that:

    LinkRef inLink
    Object obj
    for obj in current Module do {
    for inLink in obj<-"*" do {
    print("sh")
    }
    }​

    Hope that helps

    Regards

    Romain



    ------------------------------
    ROMAIN BARTH
    ------------------------------



  • 3.  RE: Looping over inlinks issue

    Posted Fri February 03, 2023 04:47 AM
    Thank you Romain

    ------------------------------
    Khalid KASSI
    ------------------------------



  • 4.  RE: Looping over inlinks issue

    Posted Fri February 03, 2023 09:50 AM
    Hi Khalid,
    if you read the manual carefully, you will notice the note "This loop only assigns to inLink incoming link values for which the source object is loaded; unloaded links are
    not detected."
    Links are stored with their source object (i.e. as outgoing links). At the other end of the link, there is no information about the link except that there is an incoming link. This is why you have to use the other loop first:

    // for each source
    for srcModName in Object tgtObject <- (string linkModName do {
    ...
    }

    This gives you the names of all the modules where there exist links to the object you are looking at.
    Once you have loaded these modules (e.g. read(srcModName)), you can loop over the actual inlinks as in your code.

    ------------------------------
    Malte Plath
    ------------------------------



  • 5.  RE: Looping over inlinks issue

    Posted Fri February 03, 2023 03:16 PM
    Thank you Malte Plath for the detailed answer.
    Well noted

    ------------------------------
    Khalid KASSI
    ------------------------------