OK, here is my solution: incoming and outgoing links2.tbx (117.8 KB)
The result looks like (expand the image to see the links!):
I’ve added 2 new String attributes,
$MyOutString. These are added to prototype ‘pNote’ KAs for testing purposes. In actual use they could be removed from the KA.
The main work is done by the ‘pNote’ $Edict:
The building blocks are links(), a numerical sort .nsort (assumes all $Names are numerical values (already set from $ID), then using list.format() to create a string which is saved for use in the template.
I did try doing the above on-the-fly within the template using
^action()^ but it fails because the in/out links to the processed note can’t (I think) be resolved in that context. The
.nsort simply ensures the notes list in consistent order (as
links() may not always generate the link list in the same order).
This is a bit of a kludge approach as we’re simply doing something hitherto not asked for. IOW, perhaps a more efficient method can be found without each not needing to store (and occasionally re-compute) it’s in/out links. I’ve assumed no aliases are in the loop - but don’t overlook that assumption as you built out your file. I’ve no idea how this file performs at scale - that for someone with the need to test.