It may be useful to store a snippet of information, such as the local sales tax percentage or the name of a certain project in a manner such as lets any note read or set that value. In programming this method is often known a a constant or global variable.
This is slightly different to setting an attribute default value whereby all attributes start with the same value. Using the local sales tax example above, it might be necessary to have a value of 0.05 (5%) that can then be used by any action code trying to figure a true sales total.
This simplest method to do this is to simply place the value in an attribute (of suitable data type) in a note outside the main content. Because it is an attribute you can both fetch the value and (re-)set it. Things to consider:
- place such value placeholder notes away from your main content so they do not accidentally get edited, e.g. in a separate branch of the root.
- for map users, place variable notes off away on the side of the map.
- give the notes unique names, allowing them to referred to by $Name alone. Otherwise, you will need to cite their $Path instead. In the case of the latter, consider keeping the path short
- a note can hold one 'variable' or several, assuming each is kept in a separate attribute. Which makes most sense is mainly down to personal choice.
- you do not need to make a $SalesTax attribute just to hold the sales tax variable. Again whether you do so is a matter of personal style; there is no right or wrong way.
- if you have, say a lot of number variables, it probably makes less sense to gives them each an attribute. Rather, use something like $NumberVariable, and store each variable in that attribute within a suitably named notes, allowing you to reference things in a manner like $NumberVariable(varLocal_Sales_Tax)
- if you are worried about user accident or code error changing an important constant value, set the note's $ReadOnly attribute to 'true' as this stops the note's attributes changing.