Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

Need a DXL script to report object statistics across all modules

 Here is the script I am am working with in DOORS 9.6.x:

pragma runLim, 10000

Module m = current
Object o = null
int reqtCount = 0

reqCount=0
load view "Public_FEAT_View"
for o in m do {
reqtCount ++
}
infoBox "There are " reqtCount " matching requirements in Pubic FEAT View"

reqtCount=0
load view "Public_TECH_View"
for o in m do { 
reqtCount ++ 
}
infoBox "There are " reqtCount " matching requirements in Public TECH View"


This script supposedly utilizes views to report back on object counts but I run into errors:

-R-E- DXL: <Line:15> null Module do loop parameter was passed
-I- DXL: execution halted

Line 15 is the first Load view call.

Thanks,
KWITS

1 vote

Comments

Where did you run this DXL?

Did you open a module and then  Tools -> Edit DXL?
In your question, you mentioned about "across all modules", are you try to iterate through all module under a folder/project?

 Good Day,


Thank you for your prompt answer! I have tried to run this script inside of a formal module and inside a project folder but to no avail but it works with views so in theory, it should work fine outside of any module. The intent of this script is to obtain a total count of objects through each respective, filtered view and output the results.

Cheers,
KWITS



5 answers

Permanent link
 Hi Keith,

Instead of using "m=current", which only works if you have a module open AND execute DXL within that module, you can use "m=read(<module-name>)" to load a module on demand before loading one or more views for that module.
You can even have multiple m=read(<module-name>) statements in your DXL to process multiple modules (in a folder or in a project or in the database, etc)

For example

pragma runLim, 10000

Module m
Object o = null
int reqtCount = 0

m=read("AMR Hazards and Risks")

reqCount=0
load view "Public_FEAT_View"
for o in m do {
reqtCount ++
}
infoBox "There are " reqtCount " matching requirements in Pubic FEAT View"

reqtCount=0
load view "Public_TECH_View"
for o in m do { 
reqtCount ++ 
}
infoBox "There are " reqtCount " matching requirements in Public TECH View"

3 votes


Permanent link
Hi Keith,

Have you tried to put the object counting codes into a function?
The following can count the objects in the "Standard view" (or any views) for as many modules as you like. There is no need to close module.

Module m

void countView(string v) {
  int reqtCount=0
  Object o
  load view v
  for o in m do { 
    reqtCount++ 
  }
  infoBox "There are " reqtCount " matching requirements in " v
}


m=read("AMR Hazards and Risks")
countView "Standard view"

m=read("AMR Stakeholder Requirements Specification")
countView "Standard view"

m=read("AMR System Requirements Specification")
countView "Standard view"

m=read("Requirements for Reuse")
countView "Standard view"

1 vote


Permanent link
 Here is my new script update. This one now works but only when you have opened a formal module and load the script there which defeats my purpose to load multiple views at once and then output the total object counts.

pragma runLim, 10000


//Intialize variables
Module m = current
Object o = null
int reqtCount = 0

if (null m)
{
    infoBox("This CETS utility can only be run within a formal module.")
    halt
}



//Count total requirement objects for the FEAT Module
reqCount=0
reqtCount=0
load view "Public_FEAT_View"
for o in m do {
reqtCount ++
}
infoBox "There are " reqtCount " matching requirements in Public FEAT View"


//Count total requirement objects for the TECH Module
reqCount=0
reqtCount=0
load view "Public_TECH_View"
for o in m do { 
reqtCount ++ 
}
infoBox "There are " reqtCount " matching requirements in Standard TECH View"


//Count total requriement objects for the BGR Module
reqCount=0
reqtCount=0
load view "Public_BGR_View"
for o in m do { 
reqtCount ++ 
}
infoBox "There are " reqtCount " matching requirements in Public BGR View"


//Count total requirement objects for the SPEC Module
reqCount=0
reqtCount=0
load view "SPEC Public View"
for o in m do { 
reqtCount ++ 
}
infoBox "There are " reqtCount " matching requirements in Standard SPEC View"

0 votes

Comments

You can open a module with the following DXL statement:

m=read(<module-name>)

Please see my answer to this question.

 Thank you for your post! Here is the code I am testing presently. Wouldn't it accomplish the same thing?


//Count total requirement objects for the FEAT Module
string sModuleFullName = "/IOC/01-Requirements/01-Functional Requirements/FEAT"
Module = module(sModuleFullName)
if (null(mCurr)) {
mCurr = read(sModuleFullName, true,true)
}
reqCount=0
reqtCount=0
load view "Public_FEAT_View"
for o in entire mCurr do {
reqtCount ++
}
infoBox "There are " reqtCount " matching requirements in Public FEAT View"

if (bClose) {
close(mCurr)
}

What is "Module = module(sModuleFullName)" doing there?

It is the same thing.
I suggested to use "read" function with module name as argument to get the module and then use for loop to loop through objects in the module.
You called "read" function with module name as argument with two extra trues to get the module and then use for loop to loop through objects in the module.

 I agree with your assessment. Your recommendation is more straight-through and it works up to two modules and then I begin to get a null value passed for the next module lookup. I think my problem is now, I need to close each module in the script after the count is rendered.

 To my knowledge all of my Public Views are identical. However, when I load my third view, I receive this error:   "null View parameter was passed into argument position 1". I have checked everything. I have verified the module properties are the same and so are the the views. Only two of my module views will load without error. I have tried calling just the "Standard View" against the other modules all without success.



Permanent link
Good Day,

Thanks to all of the feedback here, my DXL script is working 100%. I even incorporated an option to output the results to a CSV file and created a toolbar drop-down option to launch the script. It runs from a dummy module called REPORT.

Cheers,
KWITS

0 votes


Permanent link

Hello Howard,  Keith,


Please, can you let me know how do I get the requirement count on project level?

Cheers,
Ganesh

0 votes

Your answer

Register or log in to post your answer.

Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,938
× 29

Question asked: Jul 09 '15, 12:58 p.m.

Question was seen: 14,925 times

Last updated: Oct 09 '17, 10:48 a.m.

Confirmation Cancel Confirm