I want to create a DXL attribute which looks at another attribute for each object (a multi ennumeration attribute), and counts how many ennumerations have been selected. |
Re: Count entries in Multi-value ennumeration You could retrieve the value and count the EOLs; I think single-enums have no EOL in which case the value is either null or not-null; and I think Multi always have an EOL even if only one is selected; you'll need to play with it. You an use the Buffer 'contains(Buf, char, offset) command in a loop, where 'char' is '\n' and offset is the previous results of contains, something like this:
Buffer buf = probeAttr_(obj, "MyMultiEnumAttr")
int Count = 0, Offset = -1,
DebugCountLoops = 0
while (true)
{ Offset = contains(buf, '\n', Offset) // ? I don't think you need "Offset+1" here?
if (Offset >= 0) //
then Count++
else break
if (DebugCountLoops++ > 20)
{ print "Debug break " Count "\t" Offset "\n"
break
}
}
delete(buf)
print "# EOLs = Count "\n"
string Value = probeAttr_(obj, "MyMultiEnumAttr")
int i, Count = 0
for (i=0; i<length(Value); i++)
{ if (Value[i] == '\n') Count++
}
print "# EOLs = Count "\n"
int NumSelectedValues if (null Value) then NumSelectedValues = 0 else NumSelectedValues = CountEOLS+1
|
Re: Count entries in Multi-value ennumeration
Awesome llandale, you're a genius! I'd have never known to look for EOL.
string Value = probeAttr_(obj, "MultiAtt")
int i, Count = 0
for (i=0; i<length(Value); i++)
{ if (Value[i] == '\n') Count++
}
//print "# EOLs = " Count "\n"
obj.attrDXLName = count ""
|
Re: Count entries in Multi-value ennumeration liamc - Mon Nov 29 11:48:26 EST 2010
Awesome llandale, you're a genius! I'd have never known to look for EOL.
string Value = probeAttr_(obj, "MultiAtt")
int i, Count = 0
for (i=0; i<length(Value); i++)
{ if (Value[i] == '\n') Count++
}
//print "# EOLs = " Count "\n"
obj.attrDXLName = count ""
|
Re: Count entries in Multi-value ennumeration |
Re: Count entries in Multi-value ennumeration Bazinga
string Value = probeAttr_(obj, "MultiAttribute")
if(Value!=null){
int i, Count = 1
for (i=1; i<length(Value); i++)
{ if (Value[i] == '\n') Count++
}
obj.attrDXLName = Count
}
|
Re: Count entries in Multi-value ennumeration liamc - Mon Nov 29 12:43:06 EST 2010 Bazinga
string Value = probeAttr_(obj, "MultiAttribute")
if(Value!=null){
int i, Count = 1
for (i=1; i<length(Value); i++)
{ if (Value[i] == '\n') Count++
}
obj.attrDXLName = Count
}
|