![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Unique Numbering for specific objects Topic Summary: Need help w/script Created On: 10-Apr-2007 19:21 Status: Post and Reply |
Linear : Threading : Single : Branch |
|
![]() |
![]()
|
![]() Answer: I suppose I'll have to get with my team and take another look at this. I appreciate everyone's input and help. | |
![]() |
|
I'm new to DOORS, but have experience with C/C++. I need to create a script that will assign a unique identifier to ONLY objects with a specific word in the text.
Any suggestions??
Thank you!
|
|
![]() |
|
![]() |
|
1) Create attribute to store unique identifier in.
2) scan module objects searching for word. 3) set created attribute to unique value you've created with an integer at the end. 4) increment integer. Alternatively you could write a DXL column that does this and but instead of setting an attribute contains a word(or words) to signify what having your desired word in the object text means (like its a requirement for example). P.S. - Does anyone know why line breaks aren't being captured in posts? It just puts the whole post on the same line and is quite annoying. ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com Edited: 11-Apr-2007 at 14:07 by David Pechacek |
|
![]() |
|
![]() |
|
Thank you so much for such a quick reply! This is exactly what I'm trying to do. I tried what you've suggested but it's not quite working. I'm going to keep working with it and greatly appreciate the help getting started.
|
|
![]() |
|
![]() |
|
I didn't read David's reply but believe that approach is different than this one:
Lets say you want the identifier to read "MyWord_nnn" where nnn is the next integer. Create the attribute 'MyWord' to house the ID, make sure attribute is defined for objects and the module. Write a script that does the following: Reads the module level value of the attribute, strip off the prefix "MyWord_" and converts the rest to an integer; if its null presume zero. Read each object in the module, skipping deleted objects. If the object doesn't contain TheWord but has a MyWord value, then delete the value (and see below). If it has TheWord and MyWord then its OK. If it has TheWord but no MyWord, then increment the last known count, assigne the prefix and that value to the object, perhaps MyWord_23. At the end of the script set the Module level value to the last known value, in this case MyWord_23. Now you've got a problem with objects that contain TheWord and are given a MyWord value, perhaps MyWord_23. Next time of TheWord has been removed it will remove MyWord, but if you reinstert TheWord that object will get a new MyWord, which is probably what you do NOT want. If so, instead of erasing MyWord when the object no longer contains TheWord, I'd be tempted to "XX" the value out, to perhaps "xxMyWord_23"; which can then be reinstated if TheWord is reinsterted into that object. Another issue is that you MAY want to insist that MyWord be sortable chronologically, in which case you'd have to insiste that "nnn" have enough digits to cover the life of MyWord. If you figure more than a 1000 objects will get values then 'nnn' would need to be 4 digits, and the first one would be "MyWord_0001" and the second "MyWord_0002" etc. Guessing the digits can be tricky, in which case go with 5. You can use functions to convert integers to strings with certain number of digits (suffix padded with zeros), but you can also cheat by simply setting the module value originally to some big number like "MyWord_10000". - Louie |
|
![]() |
|
![]() |
|
I did try David's approach and I did get the assigned numbers, but on the wrong levels. Pretty much, what I need to do is find each object that contains "shall" and assign it a unique identifier that is different than the Object ID. I want to have my actual requirements numbered sequentially. The script I have now is assigning numbers to the headings.
|
|
![]() |
|
![]() |
|
That should assign the number to each object where the object text contains shall. Headings should not have any object text. And when you're assigning the unique identifier to the object, the object being referenced should still be the object where the object text contained "shall". So I don't see how my code could be assigning the unique identifier to a heading object above the object containing the requirement.
Copy and paste in a reply your code so I can see it. You aren't putting this code in a layout dxl column or an dxl attribute are you? Edit: I did have a break in there that shouldn't be there but that wouldn't have caused the unique identifier to be put in a different object than where the "shall" was found. ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com Edited: 11-Apr-2007 at 17:28 by David Pechacek |
|
![]() |
|
![]() |
|
Here's what I ran yesterday. I tried modifying it and rerunning and now I'm getting an incorrect regular expression error.
|
|
![]() |
|
![]() |
|
Try changing your if statement to:
if(!null(stringOf(objText)) && matches(stringOf(objText), findWord)) { This should let it skip your headers (where object text should be blank) and anywhere else object text is blank. I also got an error where it was assigning a unique ID to objects where the object text was blank. Odd. Is that what you were referring to? That it was assigning IDs to requirements but also headers or just the header instead of the requirement? Where are you getting the regular expression error? ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com Edited: 11-Apr-2007 at 19:49 by David Pechacek |
|
![]() |
|
![]() |
|
It's giving me that on line 9. Not sure why...
|
|
![]() |
|
![]() |
|
Is that the if statement or the assignment line underneath. You have a leading blank line so I'm not sure if you mean line 9 starting from the first line of code or line 9 starting from that blank line?
I copied and pasted the code you posted and it doesn't give any errors but puts the IDs in every column (and I have no object text. I change the if statement to mine and no errors and it doesn't put IDs in any column (as it should). ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com Edited: 11-Apr-2007 at 21:31 by David Pechacek |
|
![]() |
|
![]() |
|
Did you use the null or matches function?
|
|
![]() |
|
![]() |
|
I used both. This was my if statement to get it to work properly.
if(!null(stringOf(objText)) && matches(stringOf(objText), findWord)) { ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com |
|
![]() |
|
![]() |
|
It seems odd to me that you can tolerate this new unique ID being changed for an object day-to-day. If the "shall be green" requirement has ID "BSDREQ_29" last week it seems very odd that you can handle it having ID "BSDREQ_30" this week, just because you added a requirement above it.
Also, you are not saving any space by staging the Object Text in a buffer, if you use stringOf(buf) later on. If you use stringOf(buf) twice (as in your later posting) then you are wasting string-table space. Just use string Text = o."Object Text" and use Text directly. Very trivial comment: Also, you are wasting some time creating and deleting the buffer inside the loop. That doesn't matter for this loop, but in general there is considerable time spent creating and deleting buffers. I'd but the create buffer before the for loop and the delete after it. - Louie |
|
![]() |
|
![]() |
|
Yes I know. If you look at the original code I wrote at the top, I used tempStringOf. It was later changed to stringOf by Terry. For almost all of my own scripts, I use tempStringOf. I just left it the way Deliah posted it after it was changed.
As far as creating and deleting buffers, I know maybe you don't need to do it that way, but it doesn't appear to have any performance impact either way even when dealing with large numbers of objects. As you say, a trivial matter and one of preference. And one of being paranoid that the buffer will retain some information from a previous iteration. ![]() ------------------------- David Pechacek AAI Services Textron dpechacek@sc-aaicorp.com David.Pechacek@gmail.com |
|
![]() |
|
![]() |
|
You know, I never really thought if using 'tempStringOf' when the value is used in a boolean comparison operation. Yes, that sounds like it might work out very well...
Did some tests a few years ago and concluded Buffer create and deletes took quite a long while. I thus modified most of my library that uses Buffers, to move the local buffer and declare it 'globally' and create it there, leaving the function to simply erase it before using it. Did some tests just now in v8.1 and it looks like the create-delete doesn't take much time at all; specifically a million creates and deletes took around 2 seconds. Maybe I need to rethink that... Attached is the test. Takes 22-24 seconds each run in v8.1, 13-15 seconds each for v7.1. - Louie |
|
![]() |
|
![]() |
|
FYI - I've tried this again with the code below and I still get the following error:
-R-E- DXL:
|
|
![]() |
|
![]() |
|
I suspect, the error is occuring because of your using Object Text in a matches expression.
Apparently you object text has some characters that the matches function interprets as regular expressions. If this is the case the easiest solution is to eliminate the matches expression. To do this --- create a filter for object that contains the shalls then run you number script. |
|
![]() |
|
![]() |
|
I agree with Ron's comment. I usually create unique numbers for my shalls by using the following, from the DOORS DXL help files:
Filters on objects that include the string text in a specific attribute attributeName. If caseSensitive is set to ExampleModule m = current Filter f = contains(attribute "Object Text", "shall", false) set f filtering on |
|
![]() |
|
![]() |
|
One typo I noticed in my script example"
mCurrentMod."Last_Used_Number" should simply be m."Last_Used_Number" - since I already declare "m" to be the current module in my first example. Chris "Mavis Beacon Teaches Typing" Annal |
|
![]() |
|
![]() |
|
I really appreciate everyone's comments and suggestions. This is turning out to be much more complicated that I though it would be!
![]() |
|
![]() |
|
Telelogic DOORS
» DXL Exchange
»
Unique Numbering for specific objects
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.