A related question:
Is there any existing solution to take user input and put a list of
tiddlers into a field? Something with dropdown/autocomplete like the
tag-picker dialog?
On Saturday, April 3, 2021 at 11:38:09 PM UTC-6 TW Tones wrote:
> Mohammadd,
>
> I just saw this now. The Count operator or count widget, with an allbefore
> can be used to count the items before a position in a list to get the N for
> the Nth.
>
> [{!!list}allbefore[string]count[]] or something similar. add[1] if needed.
>
> Tones
>
>
> On Tuesday, 23 March 2021 at 22:16:08 UTC+11 Mohamed Amin wrote:
>
>> Thanks @Mat this is a clever workaround solution.
>>
>> @Tones, thanks for your reply, but I couldn't get your idea, how can I
>> use "range operator" to calculate the number "N" that I'll use in the
>> "nth[N]" operator?
>>
>>
>> On Tuesday, March 23, 2021 at 12:34:00 PM UTC+2 TW Tones wrote:
>>
>>> Mats suggestion is one I use.
>>>
>>> Another trick is to use count to get the total number T of items then
>>> use a range operator from 1 to N, in which the current tiddler will be the
>>> item number.
>>>
>>> However you then need to retrieve the nth[N] item from the list.
>>>
>>> Regards
>>> Tones
>>>
>>> On Tuesday, 23 March 2021 at 21:24:41 UTC+11 Mat wrote:
>>>
>>>> You can use this to find the position of an item in a list
>>>>
>>>> +[allbefore<item>count[]add[1]]
>>>>
>>>> e.g
>>>>
>>>> {{{ one two three four five +[allbefore[four]count[]add[1]] }}} ----> 4
>>>>
>>>> Not sure it's the optimal solution, I just made it up.
>>>>
>>>> <:-)
>>>>
>>>>
>>>>
>>>> On Tuesday, March 23, 2021 at 10:57:48 AM UTC+1 Mohamed Amin wrote:
>>>>
>>>>> Hi,
>>>>>
>>>>> Is there a way to get the position of an item in a "list field"?
>>>>>
>>>>> More info:
>>>>> Recently I've discovered the "nth" filter operator
>>>>> <https://tiddlywiki.com/#nth%20Operator>, and one of the use case I
>>>>> immediately think about was to "iterate" through items in multiple
>>>>> related
>>>>> "list fields"
>>>>>
>>>>> Take the following example (not a real one, just to get the idea
>>>>> clear):
>>>>> If a family needs to manage its friends, each family member's Tiddler
>>>>> will have the following fields:
>>>>> 1- friend-names : "list field" contains ALL friends
>>>>> 2- friendships-start-date : "list field" where the "position" of the
>>>>> date determine the friend's names
>>>>> 3- friendships-meter : "list field" where the "position" of the %
>>>>> determine the friend's names
>>>>>
>>>>> Ex.
>>>>> friend-names : [[alex]] [[andy]]
>>>>> [[john]] [[evan]]
>>>>> friendships-start-date : [[Mar2015]] [[Dec2017]] [[Nov2016]]
>>>>> [[Feb2011]]
>>>>> friendships-meter [[70]] [[30]]
>>>>> [[60]] [[90]]
>>>>>
>>>>> Now I can use the filter "[contain:friend-name[alex]]" to get all
>>>>> family members who is a friend with "alex".
>>>>> And if I know the <<position>> of "alex" in the "friend-names" field,
>>>>> I can get the rest of the data corresponding to it for the currentTiddler
>>>>> using a filter like:
>>>>> "[all[current]get[friendships-meter]enlist-input[]nth<position>]"
>>>>>
>>>>> Regards
>>>>>
>>>>>
--
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/tiddlywiki/7ec09788-4b96-4167-8c39-ee47b4650d41n%40googlegroups.com.