Using a variable from a filter expression

Change the first four lines from this:

<$vars now_date=<<now YYYY-0MM-0DD>>>
<$vars target={{{ [<now_date>] }}}>
<<target>>

<$vars todayfilter="[get[task_date]compare:string:eg[<target>]]">

to this:

<$vars target=<<now YYYY-0MM-0DD>>>
<<target>>

<$vars todayfilter="[get[task_date]compare:string:eq<target>]">

Notes:

  • The results of the <<now>> macro are directly stored in the target variable. There is no need for the extra step of wrapping it inside a “filtered transclusion”.
  • The compare operator’s “mode” should be “eq” (as in “equal”), not “eg”
  • The description of the syntax for compare (see https://tiddlywiki.com/#compare%20Operator) may be confusing, in that it uses “[<operand>]” to show where a literal value should be inserted; e.g. “[3]”. However, because in this case the operand is actually a variable reference, you omit the square brackets around it, and just use <target>
  • Also, instead of using the compare:string:eq filter operator for checking a text value, you can use the much simpler match filter operator, like this:
    <$vars todayfilter="[get[task_date]match<target>]">

P.S. In Discourse, when posting code containing angle brackets, you should select the code text and use the </> button (or press ctrl-E) in the editor to make the code “preformatted” so that the angle brackets and enclosed syntax aren’t treated as embedded HTML, but instead appear exactly as entered.

Let me know how it goes…

enjoy,
-e

@EricShulman you got bitten by the “admin” bug. Admins have permission to post replies sent to the GG.

Rather than leave yours as the only reply, I’ve split it off into a new thread that links to the original:

Hi,

It seems that talk.tiddlywiki should replace Google Group, shoudn’t it ?
So I post here my last comment after the Eric’s answer

I arrive now to a Tiddly javascript exception problem when I use the filter operator

My code is the following

<$vars target=<<now YYYY-0MM-0DD>>>
<<target>>
<$vars todayfilter="[get[task_date]match<target>]">
<table><tbody>

<$list filter="[regexp[db___]!sort[task_start_time]filter<todayfilter>]">
<tr>
<td><$link><$view field="task_date"/></$link></td>
<td><$view field="tags"/></td>
<td><$view field="task_comment"/></td>
<td><$view field="task_start_time"/></td>
<td><$view field="task_end_time"/></td>
</tr>
</$list>
</tbody></table>

To generate the exception you need at least one tiddler containing the required field.
I’ve prepared a tiddlywiki for your convenience to see the bug.
As I cannot attach any item from this forum please look at the GG post here https://groups.google.com/g/tiddlywiki/c/XW-t1KWeDt8

I don’t see how to solve that

Your help would be very much appreciated

Regards

Vpl

This is a known bug in the filter operator when it’s operand uses another variable, that has been fixed for the next TiddlyWiki release 5.2.0

I’m on a touch device which makes it difficult to write code, hopefully someone else can suggest workarounds.

Hi,

Thanks a lot. Yes definitely, you are right. This is fixed with the 5.2.0. I’ve tested with the pre-release and this works !!

Any workaround ?

Thanks a lot
regards