values("SomeAttr") is whole-doc scope by default, i.e. all discrete values of attribute ‘SomeAttr’ across the entire TBX. But if one wanted the same but for part of the TBX a scoped
collect_if() was the way to go.
To address the latter values was extended to allow an additional optional scoping argument to restrict the range of notes it checked. Note that, unusually, the optional second parameter is supplied as the first parameter as is explained in my notes on values().
Although less pertinent in the example at the end of the previous post, be aware that
collect_if() return a List rather than a Set so it may contain duplicates. In such a situation, chin in
.unique. As the list is not necessarily sorted, it can help to chin
.sort as well. So, adapting the earlier example to use $Tags - where dupes might well occur:
$Text=collect(descendants("Gateway Offboarding Flows"),$Tags).unique.sort.replace(";","\n");
By comparison, neither extra operator is needed here:
$Text=values(descendants("ANOTHER NOTE NAME"),"Tags").replace(";","\n");
values() returns a Set so is automatically de-duped and the values are lexically sorted as would be done by
So the two-parameter
values() syntax is simpler for a scoped value listing as it does some of the likely desired mis-en-place for you. Thus for new code, I’d go with that over
collect(). But, I’d not rush to change existing use of the latter; if it already work, it’s fine as it is.