Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
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
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 22-Nov-2006 15:21
User is offline View Users Profile Print this message


Kristian Bøe

Posts: 29
Joined: 16-Jun-2003

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
Report this to a Moderator Report this to a Moderator
 22-Nov-2006 15:32
User is offline View Users Profile Print this message


Antonio Norkus

Posts: 109
Joined: 28-Jun-2003

Are you forgetting to populate your IMapping array when you looping through the existing values?
Report this to a Moderator Report this to a Moderator
 22-Nov-2006 19:52
User is offline View Users Profile Print this message


Dan Hopping

Posts: 75
Joined: 21-Nov-2002

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

Report this to a Moderator Report this to a Moderator
 23-Nov-2006 08:25
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

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
Report this to a Moderator Report this to a Moderator
 20-Apr-2007 07:45
User is offline View Users Profile Print this message


Lucian Bodron

Posts: 24
Joined: 12-Oct-2005

And how do you populate the mapping? I have found no record of this in the DXL manual. What's the mapping variable name?
Report this to a Moderator Report this to a Moderator
 20-Apr-2007 07:51
User is offline View Users Profile Print this message


Lucian Bodron

Posts: 24
Joined: 12-Oct-2005

Found it:
int mapping[enumerationSize]
for ( count = 0; count < enumerationSize; count++ ) {mapping[count] = count}
Report this to a Moderator Report this to a Moderator
 20-Apr-2007 09:21
User is offline View Users Profile Print this message


Lucian Bodron

Posts: 24
Joined: 12-Oct-2005

It works fine!

Edited: 20-Apr-2007 at 09:32 by Lucian Bodron
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 2 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 2 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.