I want help in debugging the below given code.
\define get-current-plus-next-links()
[[$(event-navigateFromTitle)$]] [[$(event-navigateTo)$]]
\end
\define get-next-links()
[[$(event-navigateTo)$]]
\end
\define custom-actions()
<$list filter="[<modifier>match[normal]]" variable=nul>
<$action-listops $tiddler="$:/StoryList" $field="list" $subfilter="+[append<get-next-links>]"/>
<$action-setfield $tiddler="$:/HistoryList" current-tiddler=<<get-next-links>>/>
<$action-navigate $to=<<get-next-links>>/>
</$list>
<$list filter="[<modifier>match[ctrl]]" variable=nul>
<$action-setfield $tiddler="$:/StoryList" $field="list" $value=<<get-current-plus-next-links>>/>
</$list>
\end
- Firstly I want to know why the below given part of the code is not working
<$action-setfield $tiddler="$:/HistoryList" current-tiddler=<<get-new-links>>/>
<$action-navigate $to=<<get-new-links>>/>
while this code is working
<$action-listops $tiddler="$:/StoryList" $field="list" $subfilter="+[append<get-next-links>]"/>
- Also I want to convert this macro to a procedure. How to do it ?
Where is your get-new-links macro defined? Is it a typo for get-next-links?
yes, that was a typo, even after fixing it, code is nor working
<$list filter="[<modifier>match[normal]]" variable=nul>
<$action-listops $tiddler="$:/StoryList" $field="list" $subfilter="+[append<get-next-links>]"/>
<$action-setfield $tiddler="$:/HistoryList" current-tiddler=<<get-next-links>>/>
<$action-navigate $to=<<get-next-links>>/>
I think the bug comes from the double square brackets added by the macro. When I look at {{$:/HistoryList!!current-tiddler}} it never contains square brackets even when tiddler title contains spaces.
Does this work?
<$action-setfield $tiddler="$:/HistoryList" current-tiddler=<<event-navigateTo>>/>
<$action-navigate $to=<<event-navigateTo>>/>
that works . Thank you @tw-FRed
Can you guide regarding how to convert this macro to a procedure ?
If I were to chose a modern form of transclusion I’d use a function instead of a procedure:
\function get-next-links()
[<event-navigateTo>format:titlelist[]]
\end
Thank you @tw-FRed. I will try this when I am back on my desktop
This is working.
But how to convert this code to a function or procedure
\define get-current-plus-next-links()
[[$(event-navigateFromTitle)$]] [[$(event-navigateTo)$]]
\end
Just the same as the first function:
\function get-current-plus-next-links()
[<event-navigateFromTitle>format:titlelist[]] [<event-navigateTo>format:titlelist[]]
\end
but this is not working in the above code - may be because the result need to be enclosed in square brackets
I see, in this case only the function’s first result is used. Try this:
\function get-current-plus-next-links()
[<event-navigateFromTitle>format:titlelist[]] [<event-navigateTo>format:titlelist[]] +[join[]]
\end
I am afraid this also is not working. May be I will be use the macro for the time being
My bad, adding a space character to the join parameter actually works, tested on tiddlywiki.com:
\function get-current-plus-next-links()
[<event-navigateFromTitle>format:titlelist[]] [<event-navigateTo>format:titlelist[]] +[join[ ]]
\end
Fred
Now it works, Thank you @tw-FRed
How did you test this in tiddlywiki.com. I was not able to test this since the value of the variables were not visible. Thats why I was soo much confused about how to solve this
Here is what I placed in a new tiddler on tiddlywiki.com for testing:
\function get-current-plus-next-links()
[<event-navigateFromTitle>format:titlelist[]] [<event-navigateTo>format:titlelist[]] +[join[ ]]
\end
<$let
event-navigateFromTitle="HelloThere"
event-navigateTo="Quick Start"
>
<<get-current-plus-next-links>>
<$button>Go!
<$action-setfield $tiddler="$:/StoryList" $field="list" $value=<<get-current-plus-next-links>>/>
</$button></$let>
<$text text={{$:/StoryList!!list}}/>
Variables are defined with a <$let> widget, thus “simulating” the navigation process.
Fred
Thank you for explaining how you debugged this issue. It is a great learning point for me. Thank you