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: Counting Multiple Enumerated values
Topic Summary: Show how many enumerated values are selected for an object
Created On: 29-Sep-2005 16:20
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.
 29-Sep-2005 16:20
User is offline View Users Profile Print this message


Rob Kohl

Posts: 7
Joined: 4-Sep-2003

The powers that be at my design center want to evaluate requirements based on how many enumerations are selected in a specific atribute. For example if the multi-valued enumeration has 6 possible entries and 3 are selected then a value of 3 needs to be displayed.

Has anyone else done this before?
Report this to a Moderator Report this to a Moderator
 29-Sep-2005 18:36
User is offline View Users Profile Print this message


Richard Good

Posts: 152
Joined: 22-Mar-2005

Sounds like an attribute dxl is needed (think the following should do you assuming you can read it, think someone in Telelogic has stuffed up this forum) string MyAttribName = "My Enumerated Attribute" AttrDef ad = find(current Module,MyAttribName) AttrType at = ad.type int i int count=0 for(i=0;i)) count++ } obj.attrDXLName = count

-------------------------
Regards,

Richard Good
Report this to a Moderator Report this to a Moderator
 29-Sep-2005 19:15
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

These facts may help: When you get the enumerated attr value the enumerations are separated by EOL characters, '\n'. Thus you algorithm is: if the Value is null then the result is zero; otherwise the result is the number of '\n' chararters found +1. You can find the number of EOLs by putting the value in a buffer and iteratively using the "contains(buff, char)" command. Looks something like attached.

- Louie
Report this to a Moderator Report this to a Moderator
 29-Sep-2005 19:24
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

I forgot to say that given the NameEnumAttr, you could derive the AttrDef, then the AttrType, then the number of Codes and the Codes themselves, then loop through the obj attribute checking for isMember(). The above code is easier, and on 2nd thought I think I'd change the function to accept the string Value and change the name of the function to "CountParagraphs"; then it could be used for other things that only we nit-wits care about.

- Louie
Report this to a Moderator Report this to a Moderator
 4-Oct-2005 08:37
User is offline View Users Profile Print this message


Paul Worrall

Posts: 87
Joined: 30-Sep-2003

Since '\n' is the newline character, perhaps "CountLines" would be a better name?
Report this to a Moderator Report this to a Moderator
 21-Oct-2005 15:59
User is offline View Users Profile Print this message


Richard Kilgore

Posts: 12
Joined: 16-Sep-2002

Louie - Can you help me by expanding on this? I need to count the number of instances of the use of each enumeration (multi-valued attr). i.e. an object can have a value of MEC and another object can have a value of MEC and C2MC. The count would then be:

MEC 2
C2MC 1

I tried using:
if (isMember((current Object)."Allocation", "MEC")) then {
allocCount1++}

if (isMember((current Object)."Allocation", "C2MC")) then {
allocCount2++}

where allocCount1 counts all instances of MEC and allocCount2 counts C2MC, etc.,

but it doesn't give me the correct metrics.

Thanks.
Report this to a Moderator Report this to a Moderator
 21-Oct-2005 16:03
User is offline View Users Profile Print this message


Richard Kilgore

Posts: 12
Joined: 16-Sep-2002

Doh!

I replaced (current Object) with o in the isMember() function:

if (isMember((current Object)."Allocation", "MEC")) then {
allocCount1++}

changed to

if (isMember(o."Allocation", "MEC")) then {
allocCount1++}

and it works.
Report this to a Moderator Report this to a Moderator
 21-Oct-2005 20:02
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Be advised that if attribute "Allocation" doesn't exist or if "MEC" or "C2MC" enumerations don't exist, your code will abort with DXL errors. You can check ahead of time or can surround your code with "noError()" then "ErrMess = lastError()", so that the DXL keep going.

- Louie
Report this to a Moderator Report this to a Moderator
 25-Oct-2005 13:42
User is offline View Users Profile Print this message


Richard Kilgore

Posts: 12
Joined: 16-Sep-2002

Thanks Louie. I'll be sure to add that handler. Udaman.
Report this to a Moderator Report this to a Moderator
 25-Oct-2005 22:33
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Yes you are right.

I do a great deal of exporting reports in text format and then invoking Word to display it. I thus tend to think in terms of MS-Word and therein '\n' is an end of the paragraph (or table row).

Perhaps "CountEOLs" may be appropriate.

- Louie
Report this to a Moderator Report this to a Moderator
 7-Nov-2005 18:02
User is offline View Users Profile Print this message


Michael Sutherland

Posts: 248
Joined: 13-Sep-2002

Rob,

Attached is an example using the methods that Louie outlined, where the enumeration values are not hard-coded in the DXL, but determined from the Attribute Type definition.

-------------------------
Michael Sutherland
michael@galactic-solutions.com
http://galactic-solutions.com

Edited: 7-Nov-2005 at 18:04 by Michael Sutherland
Report this to a Moderator Report this to a Moderator
 7-Nov-2005 23:01
User is offline View Users Profile Print this message


Louie Landale

Posts: 2070
Joined: 12-Sep-2002

Don't forget to insure that the at.type "" == "Enumeration", otherwise your at.size will cause DXL errors.

- Louie
Report this to a Moderator Report this to a Moderator
 12-Apr-2007 16:41
User is offline View Users Profile Print this message


Karen Pulliam

Posts: 19
Joined: 18-Aug-2006

I have copy and paste this code and change the bValue and attribute type and get an error at

if (Offset < 0) Found = false


invalue use of (if) what does that mean

I'm not a programmer
Report this to a Moderator Report this to a Moderator
 12-Apr-2007 16:45
User is offline View Users Profile Print this message


David Pechacek

Posts: 674
Joined: 5-Dec-2006

Make sure you didn't accidentally delete a (, ), {, or } somewhere above that.

-------------------------
David Pechacek
AAI Services Textron
dpechacek@sc-aaicorp.com
David.Pechacek@gmail.com
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 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 1 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.