Macro

41 views
Skip to first unread message

vinvi...@gmail.com

unread,
Feb 5, 2023, 10:24:48 AM2/5/23
to TiddlyWiki
Hi, I'm trying to make a macro.

This is my code so far:

\define checkbox-list()<$list variable="LIST-FROM-FIELD" filter="[list[!!LIST-FROM-FIELD]]"><br><$checkbox listField="WRITE TO FIELD" checked=<<LIST-FROM-FIELD>>> <<LIST-FROM-FIELD>></$checkbox></$list>

It now reads the values from a field and displays them with a checkbox in front of them.
By checking the checkbox, the corresponding value is written to another field.

I would prefer that when calling the macro I could determine which values should be displayed
without having to put them in a field.

Something like:
<<checkbox-list "values to list" "Name-field-to-write-to">>

I've been working on $myvar$. and enlist $mylist$.. I can't figure it out.

Is there anyone who can help me with this?

Eric Shulman

unread,
Feb 5, 2023, 11:03:31 AM2/5/23
to TiddlyWiki
Give this a try:
```
\define checkbox-list(values,fieldname)
<$list filter="[enlist[$values$]]" variable="thisValue" >
<div><$checkbox listField="$fieldname$" checked=<<thisValue>>> <<thisValue>></$checkbox></div>
</$list>
\end
```
Notes:
* If the `values` list has items that contain double quotes or square brackets, those characters will interfere with the parsing of the `$list` filter syntax.  To avoid this problem, instead of writing `filter="[enlist[$values$]]"`, you can write: `filter="[enlist<__values__>]"`.  see https://tiddlywiki.com/#Macro%20Definitions%20in%20WikiText for more info.
* Note also that, while brackets (square, angled, or curly) within wikitext syntax are doubled, when used in filter syntax, they are SINGLE (i.e., `[enlist<__values__>]`... NOT `[enlist<<__values__>>]`)

enjoy,
-e

vinvi...@gmail.com

unread,
Feb 5, 2023, 5:24:41 PM2/5/23
to TiddlyWiki
Thank you  Eric Shulman, it works.


Op zondag 5 februari 2023 om 17:03:31 UTC+1 schreef Eric Shulman:
Reply all
Reply to author
Forward
0 new messages