Suppression of Unknown Object attribute with dxl

I am trying to iterate through objects and re-assign an object's attribute value to something else. My script runs fine until it fails due to unknown Object attribute failure. I have tried checking for the attribute's existence  with a statement like this:

Object o = current

if(exists(attribute("DXL Test"))){
      o."DXL Test" = "NEW"
     }

I have also tried to check with a statement like this:

Module m = current
Object o

AttrDef ad = find(m, "DXL Test")
if(ad.object){
    o."DXL Test" = "NEW"
}

How can I check for an attribute's existence in each object before changing the value?


Austin.Gardner - Thu Sep 17 09:46:08 EDT 2015

Re: Suppression of Unknown Object attribute with dxl
EHcnck - Thu Sep 17 11:45:29 EDT 2015

Module m = current
Object o = null

AttrDef ad = find(m, "DXL Test")

if ( null ad ) halt
if ( !ad.object ) halt

for o in entire m do {
        if ( null o ) continue
        if ( isDeleted o ) continue
        o."DXL Test" = "NEW"
}

 

Re: Suppression of Unknown Object attribute with dxl
Austin.Gardner - Thu Sep 17 14:29:35 EDT 2015

EHcnck - Thu Sep 17 11:45:29 EDT 2015

Module m = current
Object o = null

AttrDef ad = find(m, "DXL Test")

if ( null ad ) halt
if ( !ad.object ) halt

for o in entire m do {
        if ( null o ) continue
        if ( isDeleted o ) continue
        o."DXL Test" = "NEW"
}

 

I believe your answer checks for if the module has the attribute, not if each object in the module has that associated attribute. Your line 4 would be perfect if there was someway to instead specify object instead of module. 

 

My problem is that I have a list of objects from Module 1 and I need to change the object attribute values of Module 2. The list of objects is based on if there is an incoming link from Module 2.

Module module2 = current
Skip objectList = create
Object refObject
Link l


for refObject in objectList do{
 for l in refObject <- "*" do{
  absno  = sourceAbsNo(l)
  objLink = source(l)
  AttrDef ad = find(module2, "DXL Test")
  if( null objLink) continue
  if( isDeleted objLink) continue
  if( null ad) continue
  if( !ad.object ) continue
   // still errors here when certain objects are passed through
  objLink."DXL Test" = "Section 2 - New"
 }
}

If you have a better way of doing this please let me know. Thanks!

Re: Suppression of Unknown Object attribute with dxl
EHcnck - Thu Sep 17 14:38:10 EDT 2015

Austin.Gardner - Thu Sep 17 14:29:35 EDT 2015

I believe your answer checks for if the module has the attribute, not if each object in the module has that associated attribute. Your line 4 would be perfect if there was someway to instead specify object instead of module. 

 

My problem is that I have a list of objects from Module 1 and I need to change the object attribute values of Module 2. The list of objects is based on if there is an incoming link from Module 2.

Module module2 = current
Skip objectList = create
Object refObject
Link l


for refObject in objectList do{
 for l in refObject <- "*" do{
  absno  = sourceAbsNo(l)
  objLink = source(l)
  AttrDef ad = find(module2, "DXL Test")
  if( null objLink) continue
  if( isDeleted objLink) continue
  if( null ad) continue
  if( !ad.object ) continue
   // still errors here when certain objects are passed through
  objLink."DXL Test" = "Section 2 - New"
 }
}

If you have a better way of doing this please let me know. Thanks!

either the attribute is made to be module level, object level or both. if create it at the object level the every object has the attribute, although may not have a value.  based on your code the child spec doesn't have the attribute your trying to set.

Re: Suppression of Unknown Object attribute with dxl
Austin.Gardner - Thu Sep 17 14:42:31 EDT 2015

EHcnck - Thu Sep 17 14:38:10 EDT 2015

either the attribute is made to be module level, object level or both. if create it at the object level the every object has the attribute, although may not have a value.  based on your code the child spec doesn't have the attribute your trying to set.

Okay, is there a way to check if the object has the attribute I am trying to set before I try and set it? Also, I am almost positive that the object has the attribute because I can go to the object that it is faulting on and see in the properties that it does in fact have that attribute.

Re: Suppression of Unknown Object attribute with dxl
EHcnck - Thu Sep 17 15:03:55 EDT 2015

Austin.Gardner - Thu Sep 17 14:42:31 EDT 2015

Okay, is there a way to check if the object has the attribute I am trying to set before I try and set it? Also, I am almost positive that the object has the attribute because I can go to the object that it is faulting on and see in the properties that it does in fact have that attribute.

is this what you want?

 

 

Module m = current
Object o = null

AttrDef ad = find(m, "DXL Test")

if ( null ad ) halt
if ( !ad.object ) halt

bool lSource(Object o) {
        LinkRef lref
        bool ret = false
        ModName_ srcModRef
        
        for lref in o<-"*" do {
                srcModRef = source lref
                if ( rootName_(srcModRef) == "yourmouldehere" ) {
                        ret = true
                        break
                }
        }
        
        return(ret)
}

for o in entire m do {
        if ( null o ) continue
        if ( isDeleted o ) continue
        if ( lSource(o) ) o."DXL Test" = "NEW"
}

 

Re: Suppression of Unknown Object attribute with dxl
llandale - Sat Sep 26 15:43:23 EDT 2015

Browsed through the replies.

EHcnck's first response is excellent:

  • Ignores the "current Module" and problems with that
  • makes sure "o" is in Module "m"
  • Makes sure "DXL Test" is in Module "m"
  • Makes sure "DXL Test" is defined for Objects
  • Checks for deleted o, since you cannot modify attr values of deleted objects

In Classic DOORS, there is no such thing as "an Attribute defined for an Object".  If the module has the attribute and the attribute is defined for Objects, then all objects in the module "have" it.  I think DOORS-NG is different in that regard.

I wonder if you have an access problem.  You can "find" an attribute in the module but cannot "see" to modify its values?  My guess would be that your attr-Value accesses are "none".  With the GUI edit the attribute and check the two "access" tabs; one is for the "Definition" which lets you change how it is defined (such as turning on/off History), the other lets you see or modify obj-attr values.

You may also want to insert a debug statement,

  • if ( !canRead(o."Test DXL")) then there is a big problem
  • if ( !canEdit(o."Test DXL")) then there is a problem

-Louie