Nth operator or alternative

Hi,

This gets the 20th word from a section of text

{{{ [field:label[A]get[text]]:map[split[ ]nth[20]] }}}

What I’d like to do is for the nth part to reference a field in another tiddler in which I can enter the number.

Perhaps there’s another way of doing it?

Regards
Jon

Use a variable or a hard coded value like below

Using variable

<$let n={{{ [<myTiddler>get[num]] }}} >
{{{ [field:label[A]get[text]]:map[split[ ]nth<n>] }}}
...
</$let>

Hard coded

{{{ [field:label[A]get[text]]:map[split[ ]nth{someTiddler!!num}] }}}

I myself prefer the first solution!!

1 Like

Hi Mohammad,

I’ve got the 2nd version working but not the first for some reason - I’ll play around with it.

Many thanks
Jon

myTiddler itself is a variable, if you use literal like the second example use this line instead of first line of previous post:

<$let n={{{ [[someTiddler]get[num]] }}} >

Or

<$let myTiddler  =  "someTiddler"
              n  = {{{ [<myTiddler>get[num]] }}} >

This is only for demonstration; it only makes sense if you use different someTiddler in other places or when this comes from a setting/config.

1 Like

Excellent
Thanks!

Jon