compare two attributes

Hello together,

I have a small problem.

I have a module which includes two attributes which have the same types as string texts.

Now I want to compare these two attributes and write 1 to a third attribute if the strings in the attributes "engine" and "dme" don't match.

I have found this code for the comparison:

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

but how can I now write the 1 to a third attribute so i can easily filter if there is a 1 for the difference between "engine" and "dme" ?

What are you thinking, will this work with the code mentioned?

Greetings and thanks for your help

Manuel
Manulito - Wed Aug 10 04:43:29 EDT 2011

Re: compare two attributes
Manulito - Wed Aug 10 04:55:46 EDT 2011

Update:

The attributes are enumerations and not srings!

Re: compare two attributes
llandale - Wed Aug 10 11:07:57 EDT 2011

Emmediate code fix:
for Enum in skp1 do
... change { if (!find(skp1, Enum)) print NameAtt1 " has enum, not in " NameAttr2 ":\t'" Enum "'\n"
... to .......{ if (!find(skp2, Enum)) print NameAtt1 " has enum, not in " NameAttr2 ":\t'" Enum "'\n"

[1] Your code prints when the Enumeated lists don't match. It has nothing to do with Objects. Not sure what "set a 3rd attribute" means in this context. Not sure what "filter" means in this context, since those involve an "Object" and you don't use objects when comparing Enumerated lists.

[2] Perhaps also you want to check for when the VALUES of the two attributes of an object don't match. That doesn't involve enumerated lists:

// For an a boolean attr-DXL perhaps named "ValuesMisMatch":
if (obj.Name1 "" != obj.Name2 "") //
then obj.attrDXLName = true
else obj.attrDXLName = false


Or an int attr setting 1 or 0.

Now do a filter depending on whether "ValuesMisMatch" is true (or 1).

Note the above can pass even when the enumerated lists don't match. If both values are null or both contain a common enum, then the values are the same.

 

 

  • Louie