[tw] Re: [TW5] Applying nth[] to an explicit list
Hi Eric, Thanks a lot for your answer ! It's much simpler and no need to define a new filter. I would never have imagined defining such a macro (myFilter) without matching "[". FrD Le mercredi 12 août 2015 20:47:09 UTC+2, Eric Shulman a écrit : > > On Wednesday, August 12, 2015 at 10:39:01 AM UTC-7, FrD wrote: >> >> \define myMacro() >>> one two three >>> \end >>> >>> <$set name="test" filter="[explicitnth[2]]"> >>> test with variable : <> >>> >>> >>> > This should also work, without needing to define a custom filter: > \define myMacro() one two three > \define myFilter() $(myMacro)$ +[nth[2]] > <$set name="test" filter=<>> > test with variable : <> > > > enjoy, > -e > > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/5187d4b9-78fe-4132-9a5b-ea5e68f02f23%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[tw] Re: [TW5] Applying nth[] to an explicit list
On Wednesday, August 12, 2015 at 10:39:01 AM UTC-7, FrD wrote: > > \define myMacro() >> one two three >> \end >> >> <$set name="test" filter="[explicitnth[2]]"> >> test with variable : <> >> >> >> This should also work, without needing to define a custom filter: \define myMacro() one two three \define myFilter() $(myMacro)$ +[nth[2]] <$set name="test" filter=<>> test with variable : <> enjoy, -e -- 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+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/f697c8ca-1d1b-4865-aedc-16f7e8df4d1b%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[tw] Re: [TW5] Applying nth[] to an explicit list
Hi, I've found my error : filter="[explicitnth[2]]" instead of : filter="[explicit[]nth[2]]" The correct code is below : \define myMacro() > one two three > \end > > <$set name="test" filter="[explicitnth[2]]"> > test with variable : <> > > > > > FrD > > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/c66509f8-b92a-42e6-a64f-4126d86a610f%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[tw] Re: [TW5] Applying nth[] to an explicit list
Hi, I've tried to solve my problem with a new filter which transforms a string of space separated values into something suitable for operators like nth[]. I've called it 'explicit'. Note that I'm not familiar with the internals of filters ! /*\ title: explicit.js type: application/javascript module-type: filteroperator Filter operator for creating explicit input from string \*/ (function(){ /*jslint node: true, browser: true */ /*global $tw: false */ "use strict"; /* Export our filter function */ exports.explicit = function(source,operator,options) { var str = operator.operand; var results = str.split(" "); return results; }; })(); So I can use : <$set name="test" filter="[explicit[one two three]nth[2]]"> test : <> The result is : test : two But if I try to use a variable it doesn't work any more : \define myMacro() one two three \end <$set name="test" filter="[explicit[]nth[2]]"> test with variable : <> So , if someone has a clue .. Thanks in advance FrD Le mardi 11 août 2015 22:55:44 UTC+2, FrD a écrit : > > > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/f4c37f08-c97c-4db4-b2dc-1208d386fbf8%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
[tw] Re: [TW5] Applying nth[] to an explicit list
Hi Jed, Thanks for answering ! Sorry I can't get anywhere with your proposal, even when I make some modifications. When thinking about my problem, I came to rephrase it in another way : How can I apply the nth[] operator to an explicit list of tiddlers titles ? (that was the title of the thread !) A filter can be an expression like [tag[test]] and I can apply the operator : [tag[test]]nth[2] But when the filter is an explicit list of tiddlers like one two three, or [[one]] [[two]] [[three]], how do I apply the nth operator to such a list (which is not generated by another operator like list[] or tag[]) ? FrD Le mardi 11 août 2015 21:09:17 UTC+2, Jed Carty a écrit : > > Here you should be able to use + in the filter. I don't know how your > macro works but if you have some normal filter expression you can do thinks > like [tag[bob]]+[nth[1]] > > If you are constructing your list differently than you may be able to use > a set widget and a macro like this: > > \define thisButton() > <$button>some button label > <$set name="val1" filter="""$(TheList)$+[nth[1]]"""> > <$set name="val2" filter="""$(TheList)$+nth[2]]"""> > > <$action-setfield $tiddler="targetTiddler" field1=<>W/> > <$action-setfield $tiddler="EssaiBouton" field2=<>/> > > \end > > <$set name=TheList value=<>> > <> > > > Hopefully that helps > > -- 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+unsubscr...@googlegroups.com. To post to this group, send email to tiddlywiki@googlegroups.com. Visit this group at http://groups.google.com/group/tiddlywiki. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/f511865c-9f19-4033-84d4-777528efddcb%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.