filter not called???

76 views
Skip to first unread message

Jean-Pierre Rivière

unread,
Apr 30, 2021, 1:42:09 PM4/30/21
to TiddlyWiki
I have a json array of objets. the following code display something like "2/project" indicating that the name I am looking (variable "ref") for is at index 2.

<$list variable=ref filter="[<proj>indexes[]addsuffix[/project]]">
  <$set name=chk filter="[<proj>getindex<ref>match<pid>then<ref>]">
    <<chk>>
  </$set>
</$list>

The following code just display the project value I want, but it has got it by inspecting the <number>/project references.

{{{
[<proj>indexes[]addsuffix[/project]filter[indexing<proj>match<pid>]]
}}}

(I am not looking to use it as a {{{ filter }}}, this is just for testing.)

indexing is a filter operator of mine such that [a]indexing[b] is the same as [b]getindex[a]

(for instance, {{{ [<proj>indexes[]indexing<proj> }}} will display (individually) all the indexed objects of the <proj> tiddler)

it's very useful, because I often build my index, but can't use it within my filter if it was not for this very operator! And remaining in the filter is a way to keep things simple (no need for boilerplate <$list>)

with this code so far so good, here is the next step: use the "filter" operator to select the good combination but instead display the reference like 2/project.

Here it is (the variable "pid" contains the project code name I am looking for):


<$set name=x filter="[<proj>indexes[]addsuffix[/project]filter[indexing<proj>match<pid>]]">
x = <<x>>
</$set>

but the result is

x = 0/project 1/project 2/project

"filter" has not selected anything.

I have developed a "dump" filter operator showing the titles waiting for the next operator in the javascript console. Nothing is shown there, indicating that the subfilter has never been called.

What's going on?

Just to be sure it's not something with my "indexing" operator, I have tested the following similar code (which would not do what I want but that's not the point here):

<$set name=y filter="[<proj>indexes[]addsuffix[/project]filter[match<ref>]]">
y(<<ref>>) = «<<y>>»
</$set>

the output is

y(2/project) = «0/project 1/project 2/project»

instead of

y(2/project) = «2/project»

So this is the very same thing which is happening.

-- 
Jean-Pierre


Saq Imtiaz

unread,
Apr 30, 2021, 1:55:14 PM4/30/21
to TiddlyWiki
Your filter isn't a valid filter :  indexing<proj>match<pid>

It is missing square brackets to start and close. Since you cannot have square brackets inside an filter operator, this is why the operand to the filter operator is a variable or text reference.

You can also use the :filter filter run prefix.

Jean-Pierre Rivière

unread,
Apr 30, 2021, 2:21:19 PM4/30/21
to TiddlyWiki
I beg your pardon' Saq, but each of my filter were well written as far as I can see.

quoting myself:



{{{
[<proj>indexes[]addsuffix[/project]filter[indexing<proj>match<pid>]]
}}}


and
 
<$set name=x filter="[<proj>indexes[]addsuffix[/project]filter[indexing<proj>match<pid>]]">
x = <<x>>
</$set>


and finally
 
<$set name=y filter="[<proj>indexes[]addsuffix[/project]filter[match<ref>]]">
y(<<ref>>) = «<<y>>»
</$set>


there is no square bracket within them. 

In fact if I try these form of writing I get nothing but an ugly error message from the browser (internal javascript error : "TypeError: widget is undefined")

<$vars ppp="[match<chk>]">
<$list variable=ref filter="[<proj>indexes[]addsuffix[/project]]">
  <$set name=chk filter="[<proj>getindex<ref>match<pid>then<ref>]">
    @<<chk>>@
<$set name=y filter="[<proj>indexes[]addsuffix[/project]filter<ppp>]">
y(<<ref>>) = «<<y>>»
</$set>
</$vars>

which is very puzzling too.

I also tried the :filter[stuff here] syntax but it was not better either.

-- 
Jean-Pierre

Saq Imtiaz

unread,
Apr 30, 2021, 3:01:30 PM4/30/21
to TiddlyWiki
Let's look at the highlighted portion of  [<proj>indexes[]addsuffix[/project]filter[indexing<proj>match<pid>]]

The first and last square brackets in the highlighted text are for the operand to the filter operator. The square brackets tells us that you are passing a literal operand, not a text reference or a variable.

The actual operand, i.e. the filter, that you pass to the filter operator is therefore:
indexing<proj>match<pid>
This is not a valid filter, it is missing opening and closing square brackets.

A valid filter would look like [indexing<proj>match<pid>] and this would need to be defined as a variable and then passed as an operand to the filter operator because of the square brackets.

Hope that helps. Have a nice weekend.

Saq

Jean-Pierre Rivière

unread,
Apr 30, 2021, 4:26:39 PM4/30/21
to TiddlyWiki
This is a subtility that you inform me there. So good, let's go along the variable for filter way. The same passage has become:

<$vars xf="[indexing<proj>match<pid>]">
<$set name=x filter="[<proj>indexes[]addsuffix[/project]filter<xf>]">
x = <<x>>
</$set>
</$vars>

and now I have a red error message from the browser: unknown widget.

Well, this is enough, let's have a week-end indeed. Thank you for your patience Saq!

Saq Imtiaz

unread,
May 1, 2021, 1:35:52 AM5/1/21
to TiddlyWiki
Now you've run into a bug. There's a PR for a fix already: https://github.com/Jermolene/TiddlyWiki5/pull/5640

Try this instead for the meantime:
[<proj>indexes[]addsuffix[/project]] :filter[indexing<proj>match<pid>]

If that still does not work it would be useful to know what the variables proj and pid are.
Note that the value of current tiddler in the :filter filter run is set to the title it is being run for each time.

I can't comment on more than syntax at the moment as I am just not used to think in terms of JSON and filters.
Reply all
Reply to author
Forward
0 new messages