Setvars syntax

89 views
Skip to first unread message

ParisWiki

unread,
Jan 6, 2016, 10:22:32 AM1/6/16
to TiddlyWiki
Hi,

In Tobias's example :

<$setvars foo="bar[7]"  _bar="a b c d e  f g h i j k">
<<foo>>
</$setvars>
the widget give "g" as the answer, which is correct.

But, if instead of letters we put numbers as data, the widget does not function properly.
Is it forbidden to use numbers or is it a bug ?

Thanks,

JCG

By the way Tobias, I am giving you five ✮✮✮✮✮ for your pedagogy !

Tobias Beer

unread,
Jan 6, 2016, 2:44:57 PM1/6/16
to tiddl...@googlegroups.com
Hi JCG,


But, if instead of letters we put numbers as data, the widget does not function properly.
Is it forbidden to use numbers or is it a bug ?

What exactly did you try? This returns 7 for me:

<$setvars foo="bar[7]"  _bar="1 2 3 4 5 6 7 8 9 10">
<
<foo>>
</$setvars>

By the way Tobias, I am giving you five ✮✮✮✮✮ for your pedagogy !

Haha, thanks. :-)

Best wishes,

Tobias. 

ParisWiki

unread,
Jan 6, 2016, 3:06:12 PM1/6/16
to TiddlyWiki

Well , I need to use a few (or many) zeros in my data. Then, the widget looses its track

<$setvars foo="bar[7]"  _bar="1 0 0 0 0 3 4 8 9 10">
<<foo>>
</$setvars>
returns 10 (not 4)

Thanks
JCG



Le mercredi 6 janvier 2016 20:44:57 UTC+1, Tobias Beer a écrit :

Tobias Beer

unread,
Jan 6, 2016, 4:48:43 PM1/6/16
to TiddlyWiki
Hi JCG,

The problem is not so much tobibeer/setvars
as it is TiddlyWiki's way of not allowing duplicate titles in filters.

Try this on TiddlyWiki.com and take a close look at the output:

{{{ 1 0 0 0 0 3 4 8 9 10 }}}

To remedy the situation, what you can do is use the tobibeer/split filter like so:

<$setvars foo="[bar[7]]"  _bar="[[1 0 0 0 0 3 4 8 9 10]split[ ]]">
<
<foo>>
</$setvars>

I also left a comment at issue 2027, which will allow me to update the split filter to properly do:

<$setvars foo="[bar[7]]"  _bar="[[]split:list{Some!!list}]">
<
<foo>>
</$setvars>

Best wishes,

Tobias.

ParisWiki

unread,
Jan 7, 2016, 1:03:20 AM1/7/16
to TiddlyWiki
Thank you Tobias,

Effectively

{{{ 1 0 0 0 0 3 4 8 9 10 }}}

does not properly take into account the actual chain of data.

And you adaptation  of the split widget does perfectly the trick.You should add this to your examples, since it is not obvious !


<$setvars foo="[bar[7]]"  _bar="[[1 0 0 0 0 3 4 8 9 10]split[ ]]">
<
<foo>>
</$setvars>


Thanks again,
Regards,
JCG

Tobias Beer

unread,
Jan 7, 2016, 7:28:21 AM1/7/16
to TiddlyWiki
Hi JCG,
 
And you adaptation  of the split widget does perfectly the trick.You should add this to your examples, since it is not obvious!
 
I created a new Examples section in my plugins wiki.

Here's your example in its own tiddler:


Best wishes,

Tobias.
Reply all
Reply to author
Forward
0 new messages