![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Modify enumeration without deleting attribute's values Topic Summary: Created On: 22-Nov-2006 15:21 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
I have an enumeration that I need to add more values to every now and again. When I write a DXL to do it (there are more than 300 modules to modify) all of the values recorded in attributes using this type are deleted. The code I use modifies the entire type/enumeration, perhaps there is a nifty Add2Enum function that I haven't found? Doing this i the GUI works just fine without deleting anything, so there must be something out there...
AttrType at = find(mMod, "Increment") if (null(at)) then { print "*** Cannot find type in " mMod."name" "\n" return } string sTemp [at.size + 1] int iTemp [at.size + 1] int iColors [at.size + 1] int iMapping[at.size + 1] string sName = at.name int lll string errrr // Collect all of the existing values for the type for (lll = 0; lll < at.size; lll++) { sTemp [lll] = at.strings [lll] iTemp [lll] = at.values [lll] iColors[lll] = at.colors[lll] } // And add the new one sTemp [lll + 0] = "2.1" iTemp [lll + 0] = 2100 iColors [lll + 0] = iColors[lll - 1] iMapping[lll + 0] = lll + 0 // Change the type modify(at, sName, sTemp, iTemp, iColors, iMapping, errrr) if (!null(errrr)) then { print errrr "\n" return } What I've been doing is to save all the values and then rewrite them to the objects after I've modified the type. To prevent the changebars, dates and history to be modified I have to modify the attribute to not record changes before and then back after... ------------------------- Kristian Bøe Extenda AB Kristian.Boe@extenda.se |
|
![]() |
|
![]() |
|
Are you forgetting to populate your IMapping array when you looping through the existing values?
|
|
![]() |
|
![]() |
|
Kristian,
I just had to do this. Simple, once you figure out what's going on. I believe the attached code will do what you want. Remove the if statement under the comment '// select module name for changes' to convert all of the modules in a folder at once. Be careful to map the existing values just as they are in the existing enumerated type, then add new values after. If you do it this way, the existing values (even in other attributes that use this type) will not be affected. Regards, Dan |
|
![]() |
|
![]() |
|
Kristian,
Antonio is right. You're missing the line 'iMapping[lll] = lll' from the loop under comment 'Collect all of the existing values for the type'. As it is, all the mappings except the last one are zero, which won't do what you want it to. Paul. ------------------------- Paul dot Tiplady at TRW dot com TRW Automotive |
|
![]() |
|
![]() |
|
And how do you populate the mapping? I have found no record of this in the DXL manual. What's the mapping variable name?
|
|
![]() |
|
![]() |
|
Found it:
int mapping[enumerationSize] for ( count = 0; count < enumerationSize; count++ ) {mapping[count] = count} |
|
![]() |
|
![]() |
|
It works fine!
Edited: 20-Apr-2007 at 09:32 by Lucian Bodron |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.