I think there were a few miss-assumptions at the start of this thread, so have made a new thread here to describe what links are/aren’t counted and whether they are available to action code.
I presume this refers to the link count in the Info tab of the Tinderbox Inspector. As further described in my new thread (above), this count can not be accessed via action code.
Note that the value of $TextLinkCount
is (internal) text-type links plus (external) web-type links. Thus if you need the count of only text-type links, use an expression like:
$TextInternalLinkCount = $TextLinkCount-$WebLinkCount
Thus, if a note has two text links and one web link, the note’s $TextLinkCount
value would be 3 whilst the user attribute $TextInternalLinkCount
would have a value of 2.
Note that $OutboundLinkCount
excludes Web links, as the target is external to the Tinderbox document. Conversely, $TextLinkCount
includes Web links: its value is (internal) text links plus (external) web links.
Thus if you need the count of only text-type links, use an expression like $TextInternalLinkCount = $TextLinkCount-$WebLinkCount
. IOW, if a note has two text links and one web link, the note’s $TextLinkCount value would be 3 but user attribute $TextInternalLinkCount would have a value of 2.
Here, I’ve slightly modified @PaulWalters’ document to add a few edge cases for testing purposes:
- the ‘Base’ container has no links.
- ‘a’ has basic links to ‘b’ and ‘c’ and a text link to ‘c’.
- ‘b’ has no links, but two aliases. One alias has a basic link to ‘a’, and the other a basic link to ‘c’.
- ‘c’ has a single web link.
- ‘c’ uses a prototype.
Notes:
- The Inspector’s link count appears one high as it includes the one web link in ‘c’. IOW, there is no calculated value for only in-document links.
- The prototype ‘Test’ is used by one not (‘c’) and thus has one basic link. But because it is of link type ‘prototype’ it is not counted in the overall Inspector link total.
- The overall sum of
$OutboundLinkCount
does correctly sum discrete internal-only links (also omitting prototype links).