Apologies for the messy code and for including the irrelevant bits.
Perhaps the problem is just that you want to set the variables curentVal,
> targetVal etc. such that they can be accessed within the Updated_status
> macro? If so, you should be able to wrap set widgets around the <$button>
> widget within the Button macro.
That's exactly what I was trying to do, except that the values for the
variables should come from fields of other tiddlers, and not from the
defining tiddler. At last, I finally got my code working by wrapping the
<$set> definitions in a <$list> filter. My initial conclusion was that if a
variable is <$set> and wrapped in a <$list> filter then its value will not
be available to a macro defined outside of that list -- this is of course
incorrect. It was, again, my own syntax error.
Jeremy, thank you again for your pointers and help. I did not correctly
close the </$set> widgets or just left them open. Also, the
<<currentTiddler>> definitions were reduntant, so I removed them altogether
and got a cleaner code.
Anyway, here's the working code (cleaned up a bit), just for the record. On
button click, the macros calculate a result using fields from tiddlers
listed by the <$list> filter, save that result in a data tiddler, which
then is transcluded next to the button that was clicked. Issue resolved :).
Thank you again Jeremy, PMario and Jed Carty for all your invaluable help
and advice.
\define Updated_status()
<<TrackerStatus $(tracker_start_date)$ $(tracker_end_date)$ $(currentVal)$
$(targetVal)$>>
\end
\define bAction()
<$action-setfield $tiddler="_data000" $index=<<currentTiddler>>
$value=$(Updated_status)$/>
\end
\define Button()
<$button actions=<<bAction>>>
⥁ Status</$button>
\end
<table>
<$list filter="[!days:tracker_start_date[-1]][days:tracker_start_date[0]]
+[tag[tracker]] +[sort[tracker_end_date]]">
<$set name=currentVal value={{!!tracker_current_value}}>
<$set name=targetVal value={{!!tracker_target_value}}>
<$set name=tracker_start_date value={{!!tracker_start_date}}>
<$set name=tracker_end_date value={{!!tracker_end_date}}>
<tr>
<td>
<$link to={{!!title}}><$view field="title"/></$link>
</td>
<td>
<$list filter='[[_data000]getindex<currentTiddler>]'
emptyMessage="@@color:#cecece;(no data)@@"><<currentTiddler>></$list>
</td>
<td>
<<Button>>
</td>
</tr>
</$set>
</$set>
</$set>
</$set>
</$list>
</table>
Best regards,
Hubert
On Friday, 3 November 2017 13:18:02 UTC, Jeremy Ruston wrote:
>
> Hi Hubert
>
> Apologies, I’m struggling a little to understand what you’re trying to do,
> and the context for the original code. Perhaps you could post an absolutely
> minimal test case that illustrates what you’re trying to do? The code in
> the original post has a bunch of styling etc. that gets in the way of
> understanding it, and it looks like it might be incomplete (eg there’s no
> closing </$set>).
>
> Perhaps the problem is just that you want to set the variables curentVal,
> targetVal etc. such that they can be accessed within the Updated_status
> macro? If so, you should be able to wrap set widgets around the <$button>
> widget within the Button macro.
>
> One little thing I noticed trying to read your original code is that
> you’ve got a macro:
>
> \define CurrentTiddler()
> <<currentTiddler>>
> \end
>
> But then you are invoking it via text substitution:
>
> <$action-setfield $tiddler="_data000" $index=$(CurrentTiddler)$ $value=$(
> Updated_status)$/>⥁Status</$button>
>
> Because there’s no wikification done during text substitution, that is
> equivalent to:
>
> <$action-setfield $tiddler="_data000" $index=<<currentTiddler>> $value=$(
> Updated_status)$/>⥁Status</$button>
>
> Best wishes
>
> Jeremy
>
>
> On 3 Nov 2017, at 13:01, hubertgk <[email protected] <javascript:>> wrote:
>
> Thank you very much for this Jeremy.
>
> With the corrected syntax, {{!!my-field-name}}, the field transclusions
> are derived from the current tiddler that's understood as the very tiddler
> that has the macro and the transclusions themselves (the 'dashboard'
> tiddler in my original description). I'm aware that this is expected
> behaviour.
>
> What I would need is transclude the fields of other tiddlers ('tracker'
> tiddlers), without explicitly specifying those tiddlers' names -- the name
> should be provided by the list filter:
>
> <$list filter="[tag[tracker]] +[sort[name]]">
>
> This is why I was trying to use <currentTiddler> as I was hoping to
> transclude the fields of a <currentTiddler> that's currently listed by the
> list filter.
>
> When I transclude fields using <currentTiddler> within the above list
> filter, the respective fields are transcluded correctly but when I use
> <$set> within the above list filter, the set values are no longer available
> to the macro that's defined outside of the above <$list></$list>.
>
> I'm sorry if that's a bit convoluted way of thinking, I'm still learning
> TW and though I've been experimenting a lot, I'm still making many basic
> mistakes in the process. That said, I'm amazed at what TW can do. Thank you
> Jeremy for creating and maintaining such an amazing tool!
>
> @PMario, thanks for your suggestions, they definitely sound interesting.
> I'll experiment with them in the future; unfortunately they don't seem to
> help in my use case.
>
> Best regards,
> Hubert
>
> On Friday, 3 November 2017 12:14:07 UTC, Jeremy Ruston wrote:
>>
>> Hi Hubert
>>
>> On 3 Nov 2017, at 10:34, hubertgk <[email protected]> wrote:
>>
>> <$set name=currentVal value={{<currentTiddler>!!tracker_current_value}}>
>> <$set name=targetVal value={{<currentTiddler>!!tracker_target_value}}>
>> <$set name=tracker_start_date value={{<currentTiddler>!!
>> tracker_start_date}}>
>> <$set name=tracker_end_date value={{<currentTiddler>!!tracker_end_date}}>
>>
>>
>> That’s the wrong syntax for transcluding a field from the current tiddler.
>>
>> The syntax for a transcluded attribute allows for the following
>> possibilities when transcluding from a tiddler field:
>>
>> {{MyTiddlerTitle!!my-field-name}}
>> {{!!my-field-name}}
>> {{MyTiddlerTitle}}
>>
>> In the first case, both the tiddler and the field are specified. In the
>> second case, the tiddler isn’t specified and so defaults to the value of
>> the currentTiddler variable. And in the third case, the field isn’t
>> specified and so defaults to “text”.
>>
>> So, perhaps try:
>>
>> <$set name=currentVal value={{!!tracker_current_value}}>
>> <$set name=targetVal value={{!!tracker_target_value}}>
>> <$set name=tracker_start_date value={{!!tracker_start_date}}>
>> <$set name=tracker_end_date value={{!!tracker_end_date}}>
>>
>> Best wishes
>>
>> Jeremy.
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "TiddlyWiki" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected] <javascript:>.
> To post to this group, send email to [email protected]
> <javascript:>.
> Visit this group at https://groups.google.com/group/tiddlywiki.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/67ebd680-0d24-4798-aece-c7f21472d80b%40googlegroups.com
>
> <https://groups.google.com/d/msgid/tiddlywiki/67ebd680-0d24-4798-aece-c7f21472d80b%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>
>
>
--
You received this message because you are subscribed to the Google Groups
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/5870d2a6-cc4a-4ca7-b50b-1c784a13d810%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.