Links counts and attributes


(Mark Anderson) #1

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:

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 $PlainLinkCount and $TextLinkCount.

Neither Browse Links nor Roadmap pop-up dialogs include Smart-type links.

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).


Agent to calculate notes' Relative Vertex Orders
(Mark Anderson) #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 . Thus, 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.


(Mark Anderson) #3

I should add that Smart links generated by typing $Text in Tinderbox, or pasting RTF text, will always be Web-type links - i.e. with external targets. It is not currently possible to generate an internal link (i.e. a text link) via auto-generated smart-link.

(Before someone suggests using a tinderbox:// protocol link, that is still not internal but an external link that will (may?) open a note in the same Tinderbox doc but via a different process).