DXL : How to list all attribute names in a current module?

91 Views Asked by At

I wrote the code below to list all attributes in a module:

Module m = current
for objAttrName in m do {
    print objAttrName "\n"
}

However, I encountered the following error:

- DXL: <Line:2> Incorrect arguments for (do)

I want that code to list all names of the attributes that exist in the current module

1

There are 1 best solutions below

0
Mike On

Note that you need to predefine the variable over which you want to iterate so DOORS knows what yo want to get: all objects in the module (type Object), all attribute types (type AttrType) in the module, all attribute definitions etc.

For your task, you can iterate over attribute definitions (type AttrDef).

This can be done using this loop

AttrDef ad
Module m = current
for ad in m do {
  if (ad.object) then print "object attribute " ad.name "\n"
  if (ad.module) then print "module attribute " ad.name "\n"
}

Edit: if you only want to iterate over all object attributes, not module attributes, you can use the the loop that you gave in the question (for string in Module), but you also need to define the variable, so, for your case just add the line

string objAttrName