This macro dynamically updates or creates a new variable.
You can also use it to create a counter that is incremented every time the macro is called.
To store a piece of data in a variable
1.In the Design tab click on Data > Update variable
PhraseExpander opens the Update variable macro window with the selected text already inserted in the contents
Create a counter with the update variable macro.
You can customize the Update variable macro through the following options:
1.Assign value: select this option if you want to assign a value to a variable
2.Append text: if this option is selected the contents will be appended to the variable (instead of replacing the existing contents)
3.Contents: the text that will be stored in the variable. This can be plain text but it can also include other macros and variables (accessible by the context menu)
4.Increment: if checked, it increments the variable by that value (you can use both positive and negative numbers and decimals). You can also use macros here.
5.Minimum number of digits: the minimum number of digits displayed (zeros will be prepended if needed).
6.Variable name: the name of the variable that will be updated. The variable name is case insensitive, so gender, Gender, GENDER will all work. If the variable doesn't exist it's automatically created.
Syntax
{#update contents -[name][append][inc][digits]#}
contents: the data that will be stored in the variable (or the increment, if the [inc option is used]
[name]: the name of the variable to update
[append]: if set to 1, the contents are appended to the current value of the variable
[inc]: if set to 1, the variable will be incremented/decremented by that value contained in the contents
[digits]: the minimum number of digits displayed (zeros will be prepended if needed). This is used only if the counter option is present
Example 1: updating the value of a variable (with the current date)
Template:
{update {#date#} -[name=today]#}
Result:
the variable called today now contains the current date.
Example 2: creating a counter
Template:
{#update 2 -[name=mycounter][inc=1]#}
Result:
a new variable called count is updated (or created) every time the macro is executed (inside the same template); it will increment the variable by one units (starting from 2). To display any output, you need to call the variable (e.g. {{mycounter}}
NOTE: the variable is reset at each template execution. If you want to reuse the value over different executions, you have to use the Set contents macro.