This page is part of a static HTML representation of the TiddlyWiki at https://tiddlywiki.com/

getindex Operator (Examples)

25th March 2023 at 4:35pm

[[$:/palettes/Vanilla]getindex[background]]
→ returns the value of property background of the DataTiddler $:/palettes/Vanilla

[all[shadows+tiddlers]tag[$:/tags/Palette]getindex[background]]
→ returns all background colors defined in any of the ColourPalettes (notice the duplicates in the resulting list)

Tip
If a data tiddler contains a property with an empty value, the empty string is not appended to the results.

[[ListopsData]getindex[DataIndex]]
→ the empty value of the property DataIndex in ListopsData is not returned by the getindex operator

[[ListopsData]has:index[DataIndex]] :map[getindex[DataIndex]]
→ also returns the empty string

The above example works by first checking if the input title has the property DataIndex and then using the Map Filter Run Prefix to replace the title with their value of that property. If the input tiddler does not have the property, an empty selection is returned. The subsequent Map Filter Run Prefix outputs an empty string when its run returns an empty selection (because the property is empty).

[[$:/palettes/Vanilla]indexes[]] :filter[[$:/palettes/Vanilla]getindex<currentTiddler>count[]compare:number:eq[0]]
→ returns those colors in $:/palettes/Vanilla which are defined, but have no value assigned

In the above example, count is used to check if getindex returns a result (i.e. the corresponding property has a value) or not.