diff --git a/editions/tw5.com/tiddlers/filters/examples/getindex.tid b/editions/tw5.com/tiddlers/filters/examples/getindex.tid index 780c09946..ca18bce84 100644 --- a/editions/tw5.com/tiddlers/filters/examples/getindex.tid +++ b/editions/tw5.com/tiddlers/filters/examples/getindex.tid @@ -1,8 +1,22 @@ created: 20150203140000000 -modified: 20170608150301791 +modified: 20230306140231272 tags: [[getindex Operator]] [[Operator Examples]] title: getindex Operator (Examples) type: text/vnd.tiddlywiki -<<.operator-example 1 "[[$:/palettes/Vanilla]getindex[background]]" "returns the value at index ''background'' of the [[DataTiddler|DataTiddlers]] [[$:/palettes/Vanilla]]">> -<<.operator-example 2 "[all[shadows+tiddlers]tag[$:/tags/Palette]getindex[background]]" "returns all background colors defined in any of the ColourPalettes">> \ No newline at end of file +<<.operator-example 1 "[[$:/palettes/Vanilla]getindex[background]]" "returns the value at index <<.value background>> of the [[DataTiddler|DataTiddlers]] [[$:/palettes/Vanilla]]">> +<<.operator-example 2 "[all[shadows+tiddlers]tag[$:/tags/Palette]getindex[background]]" "returns all background colors defined in any of the ColourPalettes">> + +[[ListopsData]] contains an empty index <<.value ~DataIndex>> which is not returned by the filter operator: +<<.operator-example 3 "[[ListopsData]getindex[DataIndex]]">> + +This filter expression can be used to return the value, even if it is an empty string: +<<.operator-example 4 "[[ListopsData]] :filter[has:index[DataIndex]] :and[getindex[DataIndex]else[]]">> + +There are 5 palettes which define the index <<.value diff-equal-background>>, but none defines a value: +<<.operator-example 5 "[all[shadows+tiddlers]tag[$:/tags/Palette]] :filter[has:index[diff-equal-background]] :map[getindex[diff-equal-background]else[]]">> +In the above example, the [[Map Filter Run Prefix]] is used instead of `:and` as it does not de-duplicate its results. + +Another way to check if an index has an empty value is to [[count|count Operator]] the results from the [[getindex Operator]]: +<<.operator-example 6 "[[$:/palettes/Vanilla]indexes[]] :filter[[$:/palettes/Vanilla]getindexcount[]compare:number:eq[0]]">> +Here, the input to `:filter` is the [[list of indexes|indexes Operator]] which are contained in [[$:/palettes/Vanilla]]. \ No newline at end of file diff --git a/editions/tw5.com/tiddlers/filters/getindex.tid b/editions/tw5.com/tiddlers/filters/getindex.tid index 89ddabb83..03302cc6b 100644 --- a/editions/tw5.com/tiddlers/filters/getindex.tid +++ b/editions/tw5.com/tiddlers/filters/getindex.tid @@ -1,17 +1,20 @@ +caption: getindex created: 20150203140000000 -modified: 20150203140000000 +modified: 20230306131335009 +op-purpose: select all values of a data property in the input titles +op-input: a [[selection of titles|Title Selection]] +op-parameter: the name of a [[property|DataTiddlers]] +op-parameter-name: P +op-output: the values of property <<.place P>> in each of the input titles tags: [[Filter Operators]] [[Field Operators]] title: getindex Operator caption: getindex -op-purpose: select all values of a data property in the input titles - -<$macrocall $name=".operator-def" -input="a [[selection of titles|Title Selection]]" -parameter="the name of a [[property|DataTiddlers]]" -paramName="P" -output="the values of property <<.place P>> in each of the input titles" -/> Each input title is processed in turn, and is ignored if it does not denote a [[data tiddler|DataTiddlers]]. If the tiddler contains property <<.place P>>, the value of that property is [[dominantly appended|Dominant Append]] to the output. +<<.tip """If a data tiddler contains index <<.place P>> with an empty value, the empty string is not appended. The following [[Filter Expression]] can be used to also return an empty string +
:filter[has:index[P]] :and[getindex[P]else[]]
""">> + <<.operator-examples "getindex">> + + diff --git a/editions/tw5.com/tiddlers/filters/has.tid b/editions/tw5.com/tiddlers/filters/has.tid index cccb152ae..f05ae1e05 100644 --- a/editions/tw5.com/tiddlers/filters/has.tid +++ b/editions/tw5.com/tiddlers/filters/has.tid @@ -1,9 +1,9 @@ caption: has created: 20140410103123179 -modified: 20190518145446047 +modified: 20230306143207920 op-input: a [[selection of titles|Title Selection]] -op-neg-output: ''without suffix''
» those input tiddlers in which field <<.place F>> does <<.em not>> exist or has an empty value
''suffix `field`''
» those input tiddlers in which field <<.place F>> does <<.em not>> exist
''suffix `index`''
» those input tiddlers in which index <<.place F>> does <<.em not>> exist -op-output: ''without suffix''
» those input tiddlers in which field <<.place F>> has a non-empty value
''suffix `field`''
» those input tiddlers in which field <<.place F>> exists +op-neg-output: ''without suffix''
» those input tiddlers in which field <<.place F>> does <<.em not>> exist or has an empty value
''suffix `field`''
» those input tiddlers in which field <<.place F>> does <<.em not>> exist
''suffix `index`''
» those input data tiddlers in which index <<.place F>> does <<.em not>> exist +op-output: ''without suffix''
» those input tiddlers in which field <<.place F>> has a non-empty value
''suffix `field`''
» those input tiddlers in which field <<.place F>> exists
''suffix `index`''
» those input data tiddlers in which index <<.place F>> exists op-parameter: the name of a [[field|TiddlerFields]]
''suffix `index`''
» those input tiddlers in which index <<.place F>> exists op-parameter: the name of a [[field|TiddlerFields]] or, optionally an [[index|TextReference]] op-parameter-name: F