Hi, |
Re: Compare two attributes with multi-value enumerated data There are two possibilities to realize a comparison (I am not sure which one is faster but always use Buffers for the tasks): a) You append a newline character to the second Attributes value (to make sure all lines have a newline at the end). Then you split up the first attributes values line by line (using a rexexp or a loop and search for (value + newline) in the second attribute. You can do the same other way around. b) You split both strings line by line and sort the values into two skip lists with key and value the lines (string keys!). Then you try to find values of the first in the second and get a "missing" information for each attribute. If you have problems with writing the code, just post them. Regards, Mathias Mathias Mamsch, IT-QBase GmbH, Consultant Requirement Engineering and DOORS |
Re: Compare two attributes with multi-value enumerated data I think you are wanting to find out if the two enumerated attributes are defined with the same enumerations; and don't really care about object values. If so ... I've scribbled this up, good luck.
AttrDef ad1 = find(mod, NameAttr1)
AttrDef ad2 = find(mod, NameAttr2)
AttrType at1 = ad1.type
AttrType at2 = at2.type
AttrBaseType abt1 = at1.type
AttrBasetype abt2 = at2.type
if (abt1 != attrEnumeration and abt2 != attrEnumeration) // neither enumerated
elseif(abt1 != attrEnumeration and abt2 == attrEnumeration) // 2 is enumerated, 1 is not
elseif(abt1 == attrEnumeration and abt2 != attrEnumeration) // 1 is enumerated, 2 is not
elseif(abt1 == attrEnumeration and abt2 == attrEnumeration)
{ // Both Enumerated
// Get list of Enumerations
Skip skp1 = createString()
Skip skp2 = createString()
int i
string Enum
for (i=0; i<at1.size; i++) put(skp1, at1.strings[i], at1.strings[i])
for (i=0; i<at2.size; i++) put(skp2, at2.strings[1], at2.strings[i])
// Find 1 enums that don't exist in 2
for Enum in skp1 do
{ if (!find(skp1, Enum)) print NameAtt1 " has enum, not in " NameAttr2 ":\t'" Enum "'\n"
}
// Find 2 enums that don't exist in 1
for Enum in skp2 do
{ if (!find(skp1, Enum)) print NameAtt2 " has enum, not in " NameAttr1 ":\t'" Enum "'\n"
}
delete(skp1)
delete(skp2)
} // end checking when both are Enumerated
|
Re: Compare two attributes with multi-value enumerated data
Hi,
attr_a = o."Attribute A"
[...]
// split the values of the first attribute
Regexp line = regexp ".*"
while (!null attr_a && line attr_a) {
if ( !isMember(o."Attribute B", attr_a[match 0]) ) {
// do something
// Contains the current value of the Attribute: attr_a[match 0]
}
// match 0 is whole of match
attr_a = attr_a[end 0 + 2:]
}
// if Attribute A is empty
if(null attr_a) {
// do something
}
|
Re: Compare two attributes with multi-value enumerated data TCDev. - Thu Apr 29 04:20:01 EDT 2010
Hi,
attr_a = o."Attribute A"
[...]
// split the values of the first attribute
Regexp line = regexp ".*"
while (!null attr_a && line attr_a) {
if ( !isMember(o."Attribute B", attr_a[match 0]) ) {
// do something
// Contains the current value of the Attribute: attr_a[match 0]
}
// match 0 is whole of match
attr_a = attr_a[end 0 + 2:]
}
// if Attribute A is empty
if(null attr_a) {
// do something
}
Some additional information about performance: My first try was to get the type of the attribute and do a loop for every element. But since the type consists of about ~30 elements and one module has about 300 objects and I am checking more than 10 modules using one script I got a timeout. That's why it was very important to split the really selected values of "Attribute A" and check them against "Attribute B". This increases performance since max. 5 values of "Attribute A" are selected each object. Thanks again for your help! Christian |
Re: Compare two attributes with multi-value enumerated data TCDev. - Thu Apr 29 04:26:25 EDT 2010 Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS |
Re: Compare two attributes with multi-value enumerated data Mathias Mamsch - Thu Apr 29 04:40:13 EDT 2010 Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS Scripts with loops, especially recursive, should be tested with an explicit limit, perhaps pragma runLim, 10000000 When done, set it to zero meaning 'no limit' pragma runLim, 0 |