How to increment a variable within a list widget?

90 views
Skip to first unread message

si

unread,
Dec 31, 2020, 12:58:06 PM12/31/20
to TiddlyWiki
Hopefully the title is clear, so there's no need to read the rest of this, but here is my specific use case in case it's helpful.

I have added tiddlers that represent keyboard shortcuts for various programs that I use. I aim to use TiddlyRemember to memorise them.

So for example I might have a tiddler called "Ctrl + Shift + C" with the following fields:
  • evernote: Create a new note.
  • chrome: Open the console.
I have generated the flashcards with the following nested list widget:

<$list filter="[tag[Keyboard shortcuts]]" variable="shortcut">

<$list filter="[<shortcut>fields[]] -[[text]] -[[tags]] -[[tmap.id]] -[[modified]] -[[created]] -[[title]]" variable="program">

<$macrocall $name=rememberq id={{{ [<shortcut>get[created]] }}}
question={{{ [<shortcut>get<program>addprefix[Keyboard shortcuts: ]addsuffix[ in ]addsuffix<program>] }}}
answer=<<shortcut>>/>

</$list>

</$list>

The only relevant part here is the "id" field of the macrocall. This needs to be unique, but currently it will not always be since I am generating multiple cards from the same tiddler. I want to add a suffix that increments for each "pass" of the list widget. Something like:

id={{{ [<shortcut>get[created]addsuffix<incremented-variable>] }}}

What would be the best way to approach this?

TW Tones

unread,
Jan 6, 2021, 1:23:24 AM1/6/21
to TiddlyWiki
Si,

If you could go a step back and explain why you need such ID's I may be able to help. What do you mean generating multiple cards?

  • Otherwise one way to to start with a list that uses the range widget to step from one to max.
  • If you have a list its possible to have filter that uses https://tiddlywiki.com/#allbefore%20Operator and count[] to get the current position in a list.
Tones

Mark S.

unread,
Jan 6, 2021, 1:02:55 PM1/6/21
to TiddlyWiki
Since your requirement is that they be unique, why not just use addsuffix<program> ?

TW Tones

unread,
Jan 6, 2021, 5:01:31 PM1/6/21
to TiddlyWiki
Mark,

Nice idea, also perhaps "Qualify" would also work. 

Regards
Tones

Reply all
Reply to author
Forward
0 new messages