[TW5] How to get the value from a field with a parameter?

164 views
Skip to first unread message

Uwe

unread,
Aug 23, 2017, 7:46:42 AM8/23/17
to TiddlyWiki

Hi dear helpers,

I want to get the school-week (UW) from the current calendar week (KW). In my attachment, the application/x-tiddler-dictionary tiddler [[KWUW]] holds the corresponding fields.

<<now WW>> works. I get the current calendar week.

{{KWUW!!35}} works too, it gives me the current school-week, but I have to give the calendar week manually.

Unfortunately, {{KWUW!!<<now WW>>}} doesn't work. ;-(

Is there a way to pick the school-week by using the current calendar week out of the fields?

BTW: Is there an easier solution for creating the contents of the tiddler [[Kalenderwochen und Unterrichtswochen 2017/18]]?

Greetings,

Uwe
UWausKW.html

Eric Shulman

unread,
Aug 23, 2017, 8:48:20 AM8/23/17
to TiddlyWiki
On Wednesday, August 23, 2017 at 4:46:42 AM UTC-7, Uwe wrote:
I want to get the school-week (UW) from the current calendar week (KW). In my attachment, the application/x-tiddler-dictionary tiddler [[KWUW]] holds the corresponding fields.
<<now WW>> works. I get the current calendar week.
{{KWUW!!35}} works too, it gives me the current school-week, but I have to give the calendar week manually.
Unfortunately, {{KWUW!!<<now WW>>}} doesn't work. ;-(

As you have discovered, you cannot simply combine TW syntax "inline" like that.

To assemble valid TW syntax by substituting values from pieces, you use a *macro*, passing in the desired value as a parameter, like this:
\define getUW(kw) {{KWUW!!$kw$}}
and then use it like this:
<$macrocall $name="getUW" kw=<<now WW>> />

or, alternatively, you can set a variable to the desired value, and reference that variable within the macro, like this:
\define getUW() {{KWUW!!$(kw)$}}
and then use it like this:
<$vars kw=<<now WW>>> <<geUW>> </$vars>

enjoy,
-e
Eric Shulman
TiddlyTools.com "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki: The Missing Manuals

Uwe

unread,
Aug 24, 2017, 2:43:32 PM8/24/17
to tiddl...@googlegroups.com
Hi Eric,

thank you very much for your solution, it works as expected. (For other users: I only had to add the tag "$:/tags/Macro" to the tiddler with holds the macro.)

Attached is a new tiddlywiki with an other problem: How can I calculate the calendar-week from the school-week (see screenshot)?



















UWausKW_02.html
Auto Generated Inline Image 1
Reply all
Reply to author
Forward
0 new messages