[TW5] Compare macro values

114 views
Skip to first unread message

TonyM

unread,
Jan 23, 2018, 9:50:38 PM1/23/18
to TiddlyWiki
Folks,

I am looking for the correct filter syntax to compare the macro values <<currentMenu>> and <<currentTiddler>>

If both are the same or if they are not

eg;

<$list filter="filter syntax" variable=name>
 <<currentMenu>> and <<currentTiddler>> are the same
</$list>

<$list filter="filter syntax2" variable=name>
 <<currentMenu>> and <<currentTiddler>> are not the same
</$list>

Further I would like a filter that is always true that reads well

<$list filter="filter syntax3" variable=name>
Allways true with Filter Syntax3
</$list>

In this case different Filter Syntax's will be used, for different results.

Regards
Tony

TonyM

unread,
Jan 23, 2018, 10:55:34 PM1/23/18
to TiddlyWiki
While I am at it a filter that is always false would complete the documentation.

I require native tiddlywiki as I am using it in a plugin.

I know Evans formulas can do it, but not in this case.

Thanks
Tony

TonyM

unread,
Jan 23, 2018, 11:07:50 PM1/23/18
to TiddlyWiki
Oops,

I think the problem I am having is the two variables somtimes refer to system Tiddlers. Those beginning $:/

Tony

Mark S.

unread,
Jan 23, 2018, 11:19:06 PM1/23/18
to tiddl...@googlegroups.com
Try the following, keeping in mind the variable/macro equivalency.

The first 2 give identical results, but one looks for equality and other for non-equality.

-- Mark

--------------------------------------------

<$vars var1="stuff" var2="stuff2">

<$list filter="[title<var1>prefix<var2>suffix<var2>]" emptyMessage="NOT EQUAL">
EQUAL
</$list>

<$list filter="[title<var1>] [title<var2>] -[title<var1>prefix<var2>suffix<var2>] +[limit[1]]" emptyMessage="EQUAL">
NOT EQUAL
</$list>

<$list filter="[title[I AM ALWAYS TRUE]]">
TRUE
</$list>

</$vars>

TonyM

unread,
Jan 24, 2018, 12:14:13 AM1/24/18
to TiddlyWiki
Thanks mark

Much appreciated.

I am building a field in which a filter can be provided that can determine the conditions in which a menu/tiddler will appear.

I think it will be a useful pattern.

Regards
Tony

TonyM

unread,
Jan 24, 2018, 12:59:33 AM1/24/18
to tiddl...@googlegroups.com
To add to marks above here is a never true state, for future readers.

<$list filter="[title[oranges]prefix[apples]suffix[apples]]" emptyMessage="always">>
Apples will never be oranges
</$list>

Regards
Tony

TonyM

unread,
Jan 24, 2018, 11:20:16 PM1/24/18
to TiddlyWiki
Mark, et al..

Unfortunately this does not seem to be working for me, even when I eliminate system tiddlers in the variables
for example;

\define showmenu(menutype:"dropdown")
<$vars
menutypeset="$menutype$" 
dropdowntype="dropdown"
inlinetype="inline"
> <$list filter="[title<menutypeset>prefix<dropdowntype>sufix<dropdowntype>]" variable=null> Do this when menutypeset = dropdown </div> </$list> </$vars> \end



On Wednesday, January 24, 2018 at 3:19:06 PM UTC+11, Mark S. wrote:

Mark S.

unread,
Jan 25, 2018, 9:13:42 AM1/25/18
to TiddlyWiki
Mis-spelling -- sb "suffix" .

Also, there is a mismatched </div>

Good luck

-- Mark

TonyM

unread,
Jan 25, 2018, 4:35:56 PM1/25/18
to TiddlyWiki
Mark, Thanks for spotting that, when you look at something so many times it is hard to notice a single character wrong.

Some kind of syntax checking errors would be helpful.

Regards
Tony

Reply all
Reply to author
Forward
0 new messages