Macro Call : Passing TiddlerName with quotations

141 views
Skip to first unread message

Mohamed Amin

unread,
Aug 24, 2020, 4:41:42 PM8/24/20
to TiddlyWiki
Hello All,

Appreciate you help regarding my below issue:

Suppose that I've a set of Tiddlers called "Recipes" ( Recipe01, Recipe02, .....) where each of them has a field called "status"

Where:
{{Recipe01!!status}} = [[This is OK]]
{{Recipe02!!status}} = [[This is OK]]
{{Recipe03!!status}} = [[This is OK]]
{{Recipe04!!status}} = [[This is "Not" OK]]
{{Recipe05!!status}} = [[This is "Not" OK]]

Also, I've a simple Macro to get all Tiddler by "status" :

```
\define getWithStatus(myStatus)
<$list filter="[all[tiddlers]contains:status[$myStatus$]]" />

\end
```

As expected, when I run the below macro command:
<<getWithStatus [[This is OK]]>>

The output is OK, I got :-
Recipe01
Recipe02
Recipe03

BUT, my problem when I run the following :
<<getWithStatus [[This is "Not" OK]]>>

where the output is (the macro content with substitution of parameter) :-
```
<$list filter="[all[tiddlers]contains:status[This is "Not" OK]]" />
```

Thanks in Advance

P.S, I've tried both """_""", and '_' for the parameter :-
<<getWithStatus """This is "Not" OK""">>
<<getWithStatus 'This is "Not" OK'>>

but I got the same output, 
Recipe03.json
Recipe05.json
Recipe01.json
Macro & Outputs.json
Recipe02.json
Recipe04.json

Saq Imtiaz

unread,
Aug 24, 2020, 4:47:29 PM8/24/20
to TiddlyWiki
Try triple quotes around the list filter:

<$list filter="""[all[tiddlers]contains:status[$myStatus$]]""" />  

Eric Shulman

unread,
Aug 24, 2020, 4:51:05 PM8/24/20
to TiddlyWiki
On Monday, August 24, 2020 at 1:41:42 PM UTC-7, Mohamed Amin wrote:
... I've a simple Macro to get all Tiddler by "status" :
\define getWithStatus(myStatus)
<$list filter="[all[tiddlers]contains:status[$myStatus$]]" />
\end
As expected, when I run the below macro command:
<<getWithStatus [[This is OK]]>>
The output is OK...
BUT, my problem when I run the following :
<<getWithStatus [[This is "Not" OK]]>>
I've tried both """_""", and '_' for the parameter :-

The problem is how you quote the filter inside the macro.  Use the tripled-quotes like this:
\define getWithStatus(myStatus)
<$list filter="""[all[tiddlers]contains:status[$myStatus$]]""" />
\end

Then, the value of $myStatus$ can contain quotes without a problem.

-e

Mohamed Amin

unread,
Aug 24, 2020, 5:02:35 PM8/24/20
to TiddlyWiki
Thanks a lot Saq and Eric,
 
YES that was the problem, and using the tripled-quotes solved it immediately 

P.S:
I've using TW5 for almost a year now, and every day I know a new (and strange) thing about this AMAZING piece of software.
Thanks to all contributions & Community 

PMario

unread,
Aug 25, 2020, 6:33:55 AM8/25/20
to TiddlyWiki
Hi Mohammad,

I'd use much simpler values for the status eg: OK and NOK or ok and nok, which are fast to type and easy to test.

just a thought.

mario

Mohamed Amin

unread,
Aug 25, 2020, 7:14:25 AM8/25/20
to TiddlyWiki
Thanks PMario for your comment,

Actually the above were not a "real" values, just a way to present my issue, in real word I'm using True/False or Yes/No (but your suggestion "ok"/"nok" are very nice too) 

Thanks again

PMario

unread,
Aug 25, 2020, 10:57:28 AM8/25/20
to tiddl...@googlegroups.com
On Tuesday, August 25, 2020 at 1:14:25 PM UTC+2, Mohamed Amin wrote:
Thanks PMario for your comment,

Actually the above were not a "real" values, just a way to present my issue, in real word I'm using True/False or Yes/No (but your suggestion "ok"/"nok" are very nice too) 

yes / no is also used by TW for several settings, because true / false ... seemed to be to "techy" ;) IMO yes and no are good! I just wanted to point out, that "terms" with no spaces are easier to handle.

-m

Rob Hoelz

unread,
Aug 25, 2020, 11:03:22 PM8/25/20
to TiddlyWiki
Hi Mohamed,

I think an alternative would be the "Parameters as Variables" syntax described here - with that, your macro would look like this:

> \define getWithStatus(myStatus)
> <$set name="myStatus" value=<<__myStatus__>> >
> <$list filter="[all[tiddlers]field:status<myStatus>]">
>
> <<currentTiddler>>
> </$list>
> </$set>
>
> \end
Reply all
Reply to author
Forward
0 new messages