I thought it might be useful to clarify the different sorts of links and their counts as it seemed to be causing confusion in this thread. Within Tinderbox there are of links:
There are two other forms of linkage that are not accessible within the action code environment:
- Hierarchical links. These are essentially implied links derived from the TBX document’s outline structure (see more on hierarchy), and generally only used in an export context.
- ‘Smart’ links. These exist only in the context of the RTFD version of $Text (i.e. the rich text version). Currently, such links are invisible to, and uncounted by, action code. A feature request to adopt smart links as text links has been made and may yet come to pass though there are currently some technical difficulties in aligning what, to the eye, otherwise look the same. Smart links are also not listed in a note’s Browse Links dialog, which can help tell the two apart.
Note that aliases may have their own inbound/outbound basic links (see more). Aliases always share the original’s $Text-anchored links (text, web, smart links).
Tinderbox provides a number of attributes to help work with counts of different link types. For any given note, there are 3 read-only Number-type System attributes that give counts of the first three link types listed above:
- $PlainLinkCount: the note’s count of outbound basic-type links.
- $TextLinkCount: the note’s count of outbound text-type links.
- $WebLinkCount: the note’s count of outbound web-type links.
There are two further read-only Number-type System attributes that give aggregate inbound/outbound links counts for a note:
- $InboundLinkCount. This is a the sum of all inbound basic and text type links.
$OutboundLinkCount. This is a sum of all outbound basic and text type links only (i.e. omitting web and smart links). IOW, a sum calculated from the sum of the note’s
The Tinderbox Inspector’s ‘Info’ tab includes a sum of all (basic+text+web) links in the current document. IOW, smart links and ‘prototype’-type basic links are omitted from the count. This count is not accessible via action code.
Note: no link count attribute include links of the ‘Prototype’ link type. A potential confusion arises because under-the-hood, when you set a note to use a prototype the result is to make a link of type ‘prototype’ from the prototype note to the inheriting note. These links are stored in the XML link table source of the TBX document like any other link and in the very early versions of Tinderbox they were included in calculated link counts. Since circa version 5, prototype links are omitted from all calculated link count attributes and counts shown in the Inspector and Get Info dialogs (they are shown in the Roadmap but there is an option to suppress such links).