[TW5] Tobias's calc plugin question (transcluding variable to until parameter)

85 views
Skip to first unread message

CL

unread,
Nov 23, 2015, 8:11:57 PM11/23/15
to TiddlyWiki
Hi.

I am trying to transclude variable into 'until parameter' to Tobias's calc plugin.
This variable is calculated by Tobia's calc plugin as well.
I couldn't find obvious way of transcluding this value into until parameter.
My first approach is to store that value into some tiddler and transclude it via macro
In my minimal test case, test1 tiddler works fine but test2 tiddler does not work.
Or, if there are other way of transclude variable to until parameter, please let me know.

Thank you.

CL



mtc.html

Jed Carty

unread,
Nov 24, 2015, 3:09:02 AM11/24/15
to TiddlyWiki
Macro parameters are not wikified before being passed to the macro. So you end up with:

<<calc !!order +1 until:{{testState!!value}} >>

with the string {{testState!!value}} passed to the macro, not the number it represents. I have some explanation of what is gong on here, it is the same problem but in a different context. The solution is the same though.

To make it work you can use something like this:

\define helperOne()
{{testState!!value}}
\end

\define button(variable)
<$button set="!!order" setTo=<<calc !!order +1 until:$variable$ >> >add</$button>
\end

\define callButton()
<$macrocall $name='button' variable=$(ThisThing)$/
>
\end

<$set name=ThisThing value=<<helperOne>>>
<<callButton>> <$view field="order"/>
</$set>

Using set widgets and macros like this can come up a lot if you make things with complex transclusions.

Eric Shulman

unread,
Nov 24, 2015, 1:08:13 PM11/24/15
to TiddlyWiki
On Tuesday, November 24, 2015 at 12:09:02 AM UTC-8, Jed Carty wrote:
To make it work you can use something like this:

\define helperOne()
{{testState!!value}}
\end

\define button(variable)
<$button set="!!order" setTo=<<calc !!order +1 until:$variable$ >> >add</$button>
\end

\define callButton()
<$macrocall $name='button' variable=$(ThisThing)$/
>
\end

<$set name=ThisThing value=<<helperOne>>>
<<callButton>> <$view field="order"/>
</$set>


This could be simplified a lot:

* although <<macro ...>> parameters are not wikified, <$macrocall ....> parameters *are*, so you can use {{...}} directly.
* after defining a variable via <$set>, you can use <<variablename>> as a widget parameter value, even when you are *not* in a macro

Thus, no need for helperOne(), callButton(), or ThisThing...
\define button(variable)
<$button set="!!order" setTo=<<calc !!order +1 until:$variable$ >> >add<
/$button>
\end
<$macrocall $name='button' variable={{testState!!value}}/
><$view field="order"/>

enjoy,
-e

CL

unread,
Nov 24, 2015, 7:01:12 PM11/24/15
to TiddlyWiki
Thank you Jed and Eric for the answer!
I have solved my problem with that answer which took me almost whole day to fix it.

Best wishes,

CL

2015년 11월 24일 화요일 오후 7시 9분 2초 UTC+11, Jed Carty 님의 말:
Reply all
Reply to author
Forward
0 new messages