[tw5] Cannot use a variable from a filter. Can someone help me ?

Hi,

I’m trying to run the following code (at the end of the message) which uses a variable called ‘target’ (that contains the current date) into a filter called todayfilter

When I set the todayfilter

<$vars todayfilter="[get[task_date]compare:string:eg[2021-08-22]]">
All works fine (I mean the list <$list filter="[regexp[db___]!sort[task_start_time]filter]">

When I set the todayfilter using the variable (as in the code below) this does not works. I’ve tested several syntax options without success …

Any expert to tell me when the syntax is wrong ?
Many thanks , Regards
Vpl

\define now_val()
<$vars now_date=<>>
<$vars target={{{ [<now_date>] }}}>
<>

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

<$list filter="[regexp[db___]!sort[task_start_time]filter]">
Date Project Task Start Stop
  //Number of tiddlers// ''<$count filter="[regexp[db___]filter]"/>''
<$link><$view field="task_date"/> <$view field="tags"/> <$view field="task_comment"/> <$view field="task_start_time"/> <$view field="task_end_time"/>

\end

<<now_val>>

I just had a quick look at your code

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

Try;
vars todayfilter="[all[current]get[task_date]compare:string:eg]"

Tones

Hi Tones
Thanks very much for this answer
I’ve tested your option and get a TiddlyError Cannot read property getVariable of undefined … I’ve attached the screenshot for référence
To ease the analysis I’ve attached the tiddywiki. When you open it you arrive to the CurrentDay tiddler which contains the code
I’ve commented the option you proposed as it triggers this error

Thanks very much for your help and support

Regards

Vpl

(Attachment Time-tracker-support.html is missing)

1 Like

Replace the first four lines of the macro with these three lines:

<$vars target=<>>

<>
<$vars todayfilter="[get[task_date]match]">

Notes:

  1. Assign the date to the target variable in one step. There’s no need for “now_date”.

  2. The filter needs preceding get[task_date], otherwise it will get the task_date value from every tiddler that has that field!

  3. The compare “mode” should be “eq” (abbreviation of “equal”) not “eg”.

  4. For a simple string comparison, you can use the “match” filter operator.

Let me know how it goes,

enjoy,
-e

Hi,
Thanks a lot; I agree for 1), 3) and 4)

But for point 2) in fact what I need to do is the following code

<$vars now_date=<>>
<>
<$vars todayfilter="[get[task_date]match]">

<$list filter="[regexp[db___]!sort[task_start_time]filter]">

<$link><$view field="task_date"/> <$view field="tags"/> <$view field="task_comment"/> <$view field="task_start_time"/> <$view field="task_end_time"/>

I use the filter operator into the list as I want to filter the tiddlers based on the task_date field
For each of the filtered tiddlers I display the fields in the table
If I put the “get[task_date]” directly into my final filter like that (<$list filter="[regexp[db___]!sort[task_start_time] [get[task_date]match ">) I do not have the tiddler fields to display

More, When I try the below code I get a Tiddler exception (attached in my previous post …)

Is there a bug in the filter operator or something wrong I’m doing ?

Regards

Thanks a lot; I agree for 1), 3) and 4)
But for point 2) in fact what I need to do is the following code

<$vars now_date=<>>
<>
<$vars todayfilter="[get[task_date]match]">

I use the filter operator into the list as I want to filter the tiddlers based on the task_date field

For each of the filtered tiddlers I display the fields in the table

Ah, yes…I see now. You do want to find all tiddlers that have a “task_date” field, not just check the current tiddler.

More, When I try the below code I get a Tiddler exception (attached in my previous post …)

Is there a bug in the filter operator or something wrong I’m doing ?

I think you missed a change on line 1. Instead of:
<$vars now_date=<>>
you want:
<$vars target=<>>

-e

You are obviously right … thanks
But even with that I still get an Tiddly exception
FOr your convenience I’ve prepared a small tiddly with the code (tiddler test) as an attachment

Open the test tiddler and replace the

<$vars todayfilter="[get[task_date]match[2021-08-23]]">

by

<$vars todayfilter="[get[task_date]match]">

You will get a javascript exception as I mentioned in the previous posts of this conversation

Is it a bug ?

Thanks for your help

Regards

(Attachment debug_pb.html is missing)

Yes it does trigger a javascript exception.

The following code does the things you want, if I have well understood your goal.

<$vars target="<>">
<$wikify name=todayfilter text="
[get[task_date]match[<>]]">
<> : <>

<$list filter="[regexp[db___]!sort[task_start_time]filter]">

<$link><$view field="task_date"/> <$view field="tags"/> <$view field="task_comment"/> <$view field="task_start_time"/> <$view field="task_end_time"/>