[TW5] list filter; How access particular element and particular output format

124 views
Skip to first unread message

Mat

unread,
May 27, 2016, 8:16:35 AM5/27/16
to tiddl...@googlegroups.com, jeremy...@gmail.com
<<mymacro "aa bb cc">> and  <<mymacro "dd [[ee ee]] ff">>

How do I access bb and [[ee ee]] only if I want the result to be:

a)  bb      and    ee ee
b)  bb       and    ee ee
c)  [[bb]]   and    [[ee ee]]

I.e three different macros (presumably using filters) but where each macros deals with the input as multiple items and where the output is in the same "format" regardless if it is a simplestring or a [[brackedted and space separated item]].

Basic question... but I trip on this constantly and get mixed variants (e.g bb but [[ee ee]], or a monolithic result that includes the whole parameter argument).

I think a comprehensive and comparative answer+examples on this belongs in the docs. (But it's not a hypothetical question, I'd really appreciate the answer).

Anyone brave enough? I'm guessing there are only a handful who even can answer it. Also partial answers are welcome, of course.

[Edit The post was clarified after PMarios reply just below.]


<:-)

PMario

unread,
May 27, 2016, 11:02:30 AM5/27/16
to TiddlyWiki, jeremy...@gmail.com
Hi Mat,
I don't understand your question. ...

If you use [[bb bb]] in your second example ... there is no bb so you can't access it.
-m

Mat

unread,
May 27, 2016, 11:14:36 AM5/27/16
to TiddlyWiki
Thanks for input. I rephrased the question so hope it makes sense now.

<:-)

Jeremy Ruston

unread,
May 27, 2016, 11:32:15 AM5/27/16
to tiddl...@googlegroups.com
Do remember that many of us read this list via email, so it's much better to repost, and not rely on people visiting the forum directly.

Best wishes

Jeremy

--
Jeremy Ruston


On 27 May 2016, at 09:14, Mat <matia...@gmail.com> wrote:

Thanks for input. I rephrased the question so hope it makes sense now.

<:-)

--
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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
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/36c28287-71cc-44d8-9ed6-75539d67bd0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

c pa

unread,
May 27, 2016, 11:53:05 AM5/27/16
to TiddlyWiki, jeremy...@gmail.com
\define mymacro(first_parameter second_parameter third_parameter)

This is the second parameter: $second_parameter$

\end

\define mymacro2(first_parameter second_parameter third_parameter)

This is the second component of the second parameter: <$set name="part" filter="$second_parameter$ +[last[]]">
<<part>>
</$set>

\end

\define mymacro3(first_parameter second_parameter third_parameter)

This is a link to the second component of the second parameter: <$set name="part" filter="$second_parameter$ +[last[]]">
<$link to=<<part>> > <<part>> </$link>
</$set>

\end

<$macrocall $name="mymacro" first_parameter="aa" second_parameter="bb gg" third_parameter="cc" />

<$macrocall $name="mymacro2" first_parameter="aa" second_parameter="bb gg" third_parameter="cc" />


<$macrocall $name="mymacro3" first_parameter="aa" second_parameter="bb gg" third_parameter="cc" />


Mark S.

unread,
May 27, 2016, 12:41:17 PM5/27/16
to TiddlyWiki, jeremy...@gmail.com
Hi Mat,

I'm sure this isn't what you want, but maybe this will help refine the question. If you want 3 different kinds of output, then you need 3 different macros.

\define mymacro1(input) <$list filter="$input$ +[nth[2]]">&#91;&#91;<$view field=title/>&#93;&#93;</$list>

\define mymacro2(input) <$list filter="$input$ +[nth[2]]"><$view field=title/></$list>

\define mymacro3(input) <$list filter="$input$ +[nth[2]]"></$list>


<<mymacro1 "aa [[bb bb]] cc">>  

<<mymacro1 "aa bb cc">>


<<mymacro2 "aa [[bb bb]] cc">>  

<<mymacro2 "aa bb cc">>



<<mymacro3 "aa [[bb bb]] cc">>  

<<mymacro3 "aa bb cc">>


<<mymacro "aa [[bb bb]] cc">>  

<<mymacro "aa bb cc">>





On Friday, May 27, 2016 at 5:16:35 AM UTC-7, Mat wrote:
<<mymacro "aa bb cc">> and  <<mymacro "dd [[ee ee]] ff">>

How do I access bb and [[bb bb]] only if I want the result to be:

1a) bb      and    ee ee
1b) bb       and    ee ee
1c) [[bb]]   and    [[ee ee]]

Mat

unread,
May 27, 2016, 6:12:11 PM5/27/16
to TiddlyWiki
On Friday, May 27, 2016 at 5:32:15 PM UTC+2, Jeremy Ruston wrote:
Do remember that many of us read this list via email, so it's much better to repost, and not rely on people visiting the forum directly.

Makes sense. But what do you think about this approach; update the original + make a new post to (only) notify about the updated original. IMO it makes sense to try and save new readers of the thread from reading the erroneous stuff.

<:-)

Mat

unread,
May 27, 2016, 6:41:07 PM5/27/16
to TiddlyWiki, jeremy...@gmail.com
c pa and Mark, I'm afraid my question was still poorly phrased (really sorry!) but I think Mark figured out most of my intentions. Will get back on details (in a few days) but big thanks!

I've also updated the original post to include this:

I.e three different macros (presumably using filters) but where each macros deals with the input as multiple items and where the output is in the same "format" regardless if it is a simplestring or a [[brackedted and space separated item]].


<:-) 

Jeremy Ruston

unread,
May 27, 2016, 6:50:42 PM5/27/16
to tiddl...@googlegroups.com
Hi Mat

Makes sense. But what do you think about this approach; update the original + make a new post to (only) notify about the updated original. IMO it makes sense to try and save new readers of the thread from reading the erroneous stuff.

Yes, that's exactly the right approach: make sure that the archive reads properly for readers in the future, while also catering for people reading now.

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 tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.

Mark S.

unread,
May 27, 2016, 8:41:04 PM5/27/16
to TiddlyWiki, jeremy...@gmail.com

I think that my macros fulfilled your requirements. If not, perhaps the example data and the expected output could be refined.
Reply all
Reply to author
Forward
0 new messages