Action code is Tinderbox's method for automation of internal tasks.
Originally, Tinderbox had 'actions' that notes applied to themselves or their children. These were written in 'Action Code' though at the time what is now 'Export Code' was generally used for internal macros (actions). In v4 and v5 this mix was clarified: Export Code moved to being for export only whilst all internal 'coding' was done using 'Action Code', i.e. the style of code used for writing actions.
Action code is now the most likely, indeed only, form of automation users are likely to meet unless they use export features to pass information out of Tinderbox.
Action Code is not a formal coding language (programmers, take note!), and being artisanal software has grown as needed: it has what it needs or its users has asked for. It may lack some features that those with a programming background might assume are 'standard'.
An action is an automatic way of setting a certain attribute to a certain value (with the exception of system read-only attributes which cannot be altered).
Meanings of Action vs. Action code
The differing occurrence of the word 'action' can be confusing.
What is an action? As originally achieved it was essentially the functionality of agent actions, rules and the OnAdd. These allowed notes to alter attribute values in themselves or their children. These were written in action code, which differed from the primary macro, i.e. internal scripting, code of the app—what is now termed export code. Note that macro also has a discrete meaning in both export code ( via ^do^) and action code (via do()).
The older form of 'action' is reflected isn a number of (Action-type) system attribute
Since action code's role expanded, an action generally refers to any complete internal macro. Generally, they way the form:
[left side] assignment [right side]
For example, at simplest:
$Color = "blue"
Or, with a degree of evaluation or either side:
$MyString("Some note") = $Color.hue
Multiple discrete (complete actions) are delimited/terminated by a semi-colon):
$Color = "blue";$AccentColor = "red";
or as a semi-colon is optional after the last/only action:
$Color = "blue";$AccentColor = "red";$Badge="ok"
Note too, that whitespace around the assignment is ignored when the app parses )'reads') action code.
All the code above is action code.
Action code syntax
For long time users of Tinderbox, action code replaces all older #-prefix query code and many ^export^ codes. Indeed, use of ^export^ code inline in actions is now discouraged (any support is only for legacy code).
(Agent) queries are also written in Action Code
Thus a query, in action code, might be:
$Name == "Foo" (is this note's title the exact string 'Foo'?)
Or, with multiple terms:
$Name == "Foo" | $Name == "Bar" (is this note's title the exact string 'Foo' OR 'Bar'?)
As well as in agents queries, are use in a number of places such as smart adornments, find() and in action operators with conditional arguments. Be aware that many operators that have a scope of action (i.e. objects read from and/or acted upon) may also define thet scope via a query.
Case sensitivity
All action code operators are always case-sensitive (unlike export codes).
Making/deleting notes: See create(), createAgent() and delete().
Action code Syntax
This is expanded upon under basic action code syntax. Note the point above re case-sensitivity.
Further discussion of use of actions:
- Actions
- OnAdd & Agent actions
- Rules
- Edicts
- Stamps
- Mouse actions
- Coloured syntax highlighting in Action code
- Basic action code syntax
- Expressions vs. Actions in Action code
- Basic Comparison Operators
- Compound Actions
- Conditional statements using multiple arguments
- Defining an 'item' object—a single item—in action code
- Defining 'group' list objects—one or more items—in action code
- Why is a text 'line' in action code actually a paragraph?
- Explicit declaration of lists using square brackets
- Explicit declaration of dictionaries using curly braces
- Punctuation and special characters in definitions, actions and expressions
- Designators in actions
- Designators
- Comments in Action code
- Action code operator terminology explained
- Variables
- Functions
- Operators
- Problematic Characters for Action code in $Name and $Path
- Conditional Actions (if clauses)
- Counting characters in strings
- Getting and setting attribute values and inheritance
- Delaying code execution in prototypes and notes using prototypes
- Stream Processing and parsing
- JSON processing
- XML processing
- Using attributes as global variables or constants
- Chaining 'dot' operators
- Look-up tables
- Actions, Stamps and Quickstamps
- Self-Cancelling Rules & Actions
- Using regular expression back-references
- Using long sections of code—code notes
- Using .each() for loops
- Constructing $Attribute references in loops
- Detecting first or last item context in loops
- Adding joins in loops
- Concatenation versus addition
- Parentheses as a guide to code execution
- Updates and cascading actions
- Optimising code for performance
- Checking and setting Time correctly in Date data
- Debugging user-written Action code
- Getting section numbering via Action code
- Moving notes by setting $Container
- Strings vs. StyledStrings in operator documentation
- Type coercion, strings and numbers
- Sorting Date-type data
See also—notes linking to here: