There is also a more compact syntax for setting variables: the <$vars> widget.
It is particularly useful when you are setting multiple variables.
Using <$set>, you need one widget for each variable, like this:
<$set name="foo" value=...>
<$set name="bar" value=...>
<$set name="baz" value=...>
... your code here...
</$set>
</$set>
</$set>
with a matching </$set> for each.
Using <$vars> you can define multiple variables with a single widget:
<$vars foo=... bar=... baz=...>
... your code here ...
</$vars>
and a single matching </$vars>
For setting of simple variables, I always use <$vars> instead of <$set>.
One exception is when you want to use the <$set filter="..."> syntax to
capture an entire list of items into a single variable, like this:
<$set name="matches" filter="[tag[foo]]">
...
</$set>
Using the above syntax, you can get a space-separated list of all titles tagged with "foo",
and store it in a single variable, "matches".
You can also use <$set> to make "conditional assignments". For example, suppose you
want to set a value based on whether or not a filter returns any results. In that case, you
can write something like:
<$set name="myvar" filter="[tag<currentTiddler>]" value=<<currentTiddler>> emptyValue="none">
...
</$set>
Note that the same result can also be achieved with the <$vars> widget, using "inline filter" syntax
combined with the "then" and "else" filter operators, like this:
<$vars myvar={{{ [tag<currentTiddler>then<currentTiddler>else[none]] }}}
...
</$vars>
The main difference here is that the <$set> syntax was created first. "inline filter" syntax,
and also the "then" and "else" filter operators were added to the TWCore much later.
I hope this explanation hasn't confused you, but simply given you more alternatives
that enhance your TW coding efforts!
enjoy,
-e