# Link Operators

links[(item)].direction.linkType.attribute builds a list from a collection of links.

item selects which note's links should be collected. It may be a single item, a list of items, or a group.If item is omitted, "this" is implied; if item is omitted the enclosing parentheses may be omitted as well. item may be a designator (e.g. "parent") or a note path (/config/details).

The argument direction is either "inbound" or "outbound".

linkType collects only links of a specified link type. linkType is a regular expression: wild-card characters are permitted and have special meanings. If linkType contains white space or periods, enclose it in quotes:

> `links.outbound."responds to".$Name`

If 'linkType' is left empty, links of all types are collected with the exception of prototype links. Prototype links are always omitted. As a regular expression, linkType may match more than one link type:

> `links.outbound."agree|clarify".$Name`

attribute is the name of the attribute whose values are to be collected in the result.

For example

> `$MySet=links(/config).outbound.supports.$Name`

constructs a list of all the Names of notes that are linked to the top-level note named config via links of type "supports".

> `$MySet=links.inbound..$Name`

collects a set of all the names of notes that are linked to this note.

> `links[(note)].kind.linkType.attribute`

#### Making Links

Four actions create or remove links between notes.

linkTo(target [,linkType])

unlinkTo(target [,linkType])

linkFrom(target [,linkType])

unlinkFrom(target [,linkType])

The first argument to each of these actions, is the name or path of a note, or a list of paths. The optional second argument is the link’s type; if no argument is supplied, untitled links are used. Unlike links(), above, the linkType argument is not a regex and is a string literal.

linkTo and linkFrom will not create a new link if the link already exists. unlinkTo and unlinkFrom will do nothing if the described link does not exist. Thus, these actions may be used in agents:

`Query: Status(urgent)` `Action: linkFrom(/agenda/today/tasks,"urgent!")`

This action will insure that an "urgent!" link runs from the note "tasks" in today's agenda; if the link already exists, the action has no effect.

If linkType is not supplied, unlink actions will remove links of all link types.