DXL Count Outlinks per object

Hello to all !

I wonder how to count inlinks/outlinks per object. My strategy was to modify a basic Wizard analysis showing linked object Identifiers. The result is below

 if (depth == 1) {
            s = (identifier othero)
            if (s == "") 
            displayRich("\\pard " " ")
            else
            displayRich("\\pard " s)

Shall replace use an incrementing counter ? I tried to use count++ but no result

 if (depth == 1) {
            count++
 }
display(count"")

Could you help me finding the way ? Half

 


Dader - Thu Aug 11 04:03:12 EDT 2016

Re: DXL Count Outlinks per object
PekkaMakinen - Thu Aug 11 05:39:32 EDT 2016

If you need to count links there is a ready-made DXL attribute code in DOORS DXL library. To use this, start to create a new attribute, check DXL Attribute and then press Browse button.

 

If you want to do it on your own, below is my version of code modified from Analysis Wizard code

 

pragma runLim, 0

int LinkCount = 0

void showOut(Object o, int depth) {
    Link l
    LinkRef lr
    ModName_ otherMod = null
    Module linkMod = null
    ModuleVersion otherVersion = null
    Object othero
    string disp = null
    string s = null
    string plain, plainDisp
    int plainTextLen
    int count
    bool doneOne = false
    string linkModName = "*"
    for l in all(o->linkModName) do {
        otherVersion = targetVersion l
        otherMod = module(otherVersion)
        if (null otherMod || isDeleted otherMod) continue
        othero = target l
        if (null othero) {
            load(otherVersion,false)
        }
        othero = target l
        if (null othero) continue
        if (isDeleted othero) continue
        doneOne = true
        if (depth == 1) {
           LinkCount++
        }
    }
   display LinkCount""  
}
showOut(obj,1)

 


Attachments

Clipboard01pm.jpg

Re: DXL Count Outlinks per object
Wolfgang Uhr - Thu Aug 11 07:11:38 EDT 2016

To count links you first need an object, let us say objWork.

Then you must not use the datatype "Link". For outlinks, that may be ok, but for inlinks it only works if the link source modules ale loaded.

int countOutlinks(Object objWork) {
  LinkRef lnkRefWork;
  int iCnt = 0;
  for lnkRefWork in (objWork -> "*") do { ++iCnt };
  return(iCnt);
}

int countInlinks(Object objWork) {
  LinkRef lnkRefWork;
  int iCnt = 0;
  for lnkRefWork in (objWork <- "*") do { ++iCnt };
  return(iCnt);
}

I hope I met the correct syntax.