![]() |
Telelogic DOORS (steve huntington) | ![]() |
Topic Title: Can value of a dxl attribute be passed to a Module level attribute automatically? Topic Summary: Created On: 9-Jan-2008 13:27 Status: Post and Reply |
Linear : Threading : Single : Branch |
|
![]() |
![]()
|
![]() |
|
This is useful especially when we want to extract into the Word Report, the name of the module and the total requirements in that module. Can this be achieved in some way?
|
|
![]() |
|
![]() |
|
I haven't tried it but you could always try to set the value of the module level attribute in the code of the DXL attribute. The module level attribute would likely retain the last calculated value of the DXL attribute. Assuming it works.
------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com |
|
![]() |
|
![]() |
|
[1] Good question, never really thought about an Attr DXL applying to the module. Did a little test, created a 'text' attr DXL that applied to Objects and the Module, and inserted the attached code.
It appears the absolute number of the module is null. [2] That's different than having a module level attribute read the value of some attr DXL of a particular object. That's easy: Object oCurr = top(current Module) // pick an object, in this case the top one obj.attrDXLName = "Value of top object = " oCurr.MyAttr "" [3] It sounds like, perhaps, what you are asking for is a module-level DXL attribute that counts the number of requirements in the module. If so, that would look like: define the attr to apply to the module only: Object oCurr int Count = 0 for oCurr in entire (current Module) do { if (isDeleted(oCurr)) continue if (oCurr is a requirement) Count++ } obj.attrDXLName = "# Reqs = " Count "" - Louie |
|
![]() |
|
![]() |
|
Hi Louie
Thanks for your help. Case 3 is what I'm trying to achieve.I need to extract all the Module names, the number of total requirements & different kinds of requirements in them, total number of baselines etc into Report using DocExpress.I thought to workaround this, I should first calculate the values using a Layout DXL or DXL attribute, and then figure out some way to pass the value to a Module attribute (For meaningful extraction by the DE).The module attribute at any time should get updated by the value of the DXL attribute. I tried using your code but ran into an error with the line: if (oCurr is a requirement) Count++ . I tried modifying & using it as follows but got an error on the last line: Object o int count=0 string s for o in current Module do { s=o."type" if(s=="requirement") { count++ }} obj.attrDXLName="#reqs="count"" I must be doing something silly. Kindly help. Regards Chaithali |
|
![]() |
|
![]() |
|
What I think I would do is created a DXL attribute called "Requirement" and have it be enumerated, "Yes" or "No". Have its value calculated per object to be yes or no depending on what you deem to be a requirement.
Have your module level attribute "Number of Requirements". Then have a pre-close trigger that loops through the module and gets the number of objects where "Requirement" is "Yes". Then set "Number of Requirements" equal to that. That way it will always be updated when the module is closed. You could also have the tool to recalculate the number of requirements accessible in your User pull down menu in case you want to calculate it on the fly. ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com |
|
![]() |
|
![]() |
|
Just in case: it would be tough to 'pass a value to' a module attribute, rather the module attr calculates it based on the value of the various objects.
First off, the 'for o in mod do' loop only sees objects in the current display set. If you change a filter than some objects won't get counted. Unless you WANT to be tied to the current view or display set, you should routinely use the 'for o in entire mod do' loop, then exclude the objects you don't want (such as the isDeleted(o) objects). What error are you getting? These attr-dxl code won't work when run from the normal DXL window; they should interpret but you can expect not-initialized errors for both 'obj' and also for 'attrDXLName'. - Louie |
|
![]() |
|
![]() |
|
Yeah, thanks. I will keep the thing about using entire module in mind.I inserted my version of the code into a column, when I clicked on the properties of the column, i get this in dxl output:
/* This attribute DXL was generated on 1/9/2008 22:39:16. */ // prevent dxl timeout dialog pragma runLim, 0 Buffer bsz = create void endAttributeDXL() { if (!null obj && attrDXLName != "") { obj.attrDXLName = richText tempStringOf(bsz) } delete bsz } void display(string s) { bsz += s bsz += "\n" } void displayRich(string s) { bsz += s bsz += "\n" } //********** 1/9/2008 22:39:16. //********** endAttributeDXL() -E- DXL: <Line:34> incorrectly concatenated tokens -E- DXL: <Line:34> syntax error -I- DXL: all done with 2 errors and 0 warnings -R-E- DXL: <Line:201> invalid dxl value for attribute '. ' of type 'Text' Backtrace: <wizard/tip/tipwiz:444> |
|
![]() |
|
![]() |
|
I'm not really sure what the code you have there is trying to achieve.
Nor do I know why it's giving an error since you've only got like 25 lines of code there and it says the error is at line 34. Is there more you're not showing us? If you want to follow my 2nd idea, I would try code like this. ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com Edited: 9-Jan-2008 at 19:09 by David Pechacek |
|
![]() |
|
![]() |
|
Am sorry. Previous error was my mistake, I had a wrong DXL attribute column.
I now created a Lyout DXL column with this code & I get the error 'incorrect return statement' and a Diagnostic log too. |
|
![]() |
|
![]() |
|
See my above post.
Also. Attribute DXL and Layout DXL are two different things. Attribute DXL should not be run in a Layout DXL Column. ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com Edited: 9-Jan-2008 at 19:07 by David Pechacek |
|
![]() |
|
![]() |
|
I have a few questions on this. What is the correct way to implement this code?
Should I first create a Layout DXL column using this code, convert it to DXL attribute & modify the attribute to be a module level attribute?Can I view the value of the module attribute in the module?Probably am doing something wrong therefore I get the error when I click on the DXL attribute column name. |
|
![]() |
|
![]() |
|
Hi David
The above comments were with regards to Louie's idea. I will try out your method and let you know how it goes. Regards Chaithali |
|
![]() |
|
![]() |
|
Should I first create a Layout DXL column using this code, convert it to DXL attribute & modify the attribute to be a module level attribute? Create two attributes an object level, enumerated, DXL Attribute called "Requirement" and a module level, integer attribute called "Number of Requirements". The first code gets put as the attribute dxl code of "Requirement". The second code is the code fired by the pre-close trigger you'll have to create. Can I view the value of the module attribute in the module? No. You cannot put a module level attribute in a column. ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com |
|
![]() |
|
![]() |
|
The code you show is how Layout DXL is converted to Attribute DXL. In a layout, 'display' and 'displayRich' commands used for output and act like print statements. To convert to Attr DXL you need new functions that accumulate the results, which is why this code has a 'display' and also a 'displayRich' functions. At the bottom of the new attr-dxl, calling function endAttributeDXL(). For example, try the following simple code, noting how the standard 'print' command can be bypassed in favor of one you write:
void print(string Message) { infoBox("This is from my new 'print' command\n" Message) } print "Hello world\n" Not sure what would happen if you used this layout-to-attrDXL code as a layout. The above is lazy way of converting layouts to attr-dxl. It would be better to just write the attr-dxl from the start. Your 1st 3 errors (line 34, line 34, all done) seems to be mentioning your '1/9/2008 ..' line which looks like a date. That line will generate the 3 errors, however they are not at line 34. Maybe white-space lines were deleted when you pasted it. That line is in the location where the layout dxl should be inserted in order to turn the mess into attr-dxl. It really should contain code, not the results of the layout. The line 201 error looks to me [1] you have an attribute name that is a period followed by an EOL. That's clearly wrong; or [2] you are assigning a period followed by an EOL to an attribute that isn't of type text; perhaps the attr-dxl is type int or string instead of Text. The backtrace error seems to be associated with the 201 error. When I investigated in v8.1, tipwiz.dxl line 444 didn't lead me to this error and I suspect this is a display bug by the DXL interpreter; thus doesn't help us find the root problems. You CAN write an attr-DXL that applies to the module and also to objects. Basically the code would have an if-else clause checking for null obj."Absolute Number". However, I have serious doubts it would work if the module-level part had an object-loop, looking at the value of all the object-level values of this same attribute. e.g. if each object displayed the number of 'shalls' in the text, and the module counted all the 'shalls' in any object; I'm not sure in which order the module or object values would be calculated, but I suppose you can give it a try. - Louie |
|
![]() |
|
![]() |
|
Thank You. I tried David's method as following:
1.Created attributes Requirement and Number of Requirements.DXL attribute Requirement works fine. 2.Placed code2 in $doorshome/lib/dxl/trigger as requirements.dxl 3.Ran the pre-close trigger on DOORS from DXL window(Trigger t2 = trigger("mod", module->all, pre, close, 10, "#include <triggers/requirements>"). 4.Now I expect attribute 'Number of Requirements' to show the value(Edit->Attributes window). But it doesn't show. Have I missed a step? |
|
![]() |
|
![]() |
|
When I tried the following the module, I could see the value of attribute "Number of Requirements". Thanks for all the help.
Module m = current Module string s=m."Number of Requirements" print s |
|
![]() |
|
![]() |
|
Be advised that other folks don't have access to your doorshome, and so when the trigger fires everyone else will get DXL errors.
Instead of using $include, you should read and then insert the code directly into the Trigger, something like this: t2 = trigger("ModReqs", module->all, pre, close, 10, readFile("triggers/requirements.dxl") - Louie |
|
![]() |
|
![]() |
|
Some additional info: I tried this->Disabled the trigger.I made the module level attribute "Number of Requirements" a DXL attribute with code2:
Object o Module m = current Module int numReqs = 0 for o in entire(m) do { if(isDeleted(o)) { continue } if(o."Requirement""" == "Yes") { numReqs++ } } m."Number of Requirements" = numReqs string s=m."Number of Requirements" display s"" Seems to work fine.The attribute holds the current value of total no. of requirements. So, can this method be used(without using triggers)? |
|
![]() |
|
![]() |
|
Not following exactly, but [1] you should use 'display' only in a layout DXL; I notice it doesn't seem to do anything in a normal DXL. [2] if 'Number of Requirements' is a Text or String attribute, you should assign it a string value not an integer value, that is do this: m."Number of Requirements" = numReqs "".
Yes, this seems better than using a Trigger. - Louie |
|
![]() |
|
![]() |
|
Yes but if its a DXL attribute, you'll have to open the module for the value to be calculated. I thought the whole point of this was to not have to open the module. Which you don't have to do to check module attributes in DOORS 8.3.
------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com |
|
![]() |
|
Telelogic DOORS
» DXL Exchange
»
Can value of a dxl attribute be passed to a Module level attribute automatically?
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.