<$list filter="[all[current]has[wiki-owner]get[wiki-owner]]" variable=null>
"<<currentWiki>>" = "{{!!wiki-owner}}" ?<br>
<$list filter="[all[current]field:wiki-owner<currentWiki>]">
<<currentTiddler>> Owns {{Certificate.svg}}
</$list>
<$list filter="[all[current]!field:wiki-owner<currentWiki>]">
<<currentTiddler>> Not {{Certificate-not.svg}}
</$list>
</$list>
<$vars test1="abc" test2="abc">
<$set name="myVariable" filter="[<test1>] -[<test2>]" emptyValue="They match" value="They dont match">
<$text text=<<myVariable>>/>
</$set>
</$vars>
<$list filter="[is[current]get[wiki-owner]] -[<this-wiki>]" variable=null emptyMessage="{{Certificate.svg}}" >
{{Certificate-not.svg}}
</$list>
<$list filter="[<this-wiki>] [{!!wiki-owner}] +[count[]] -[[2]]"> same </$list>
<$list filter="[<this-wiki>] [{!!wiki-owner}] +[count[]] -[[1]]"> different </$list>
\define currentWiki() {{$:/PSaT/wikimanager/wiki-tiddler##wiki-title}}
<<currentWiki>>
<$list filter="[<currentWiki>] [{!!wiki-owner}] +[count[]] -[[2]]">
same {{Certificate.svg}}
</$list>
<$list filter="[<currentWiki>] [{!!wiki-owner}] +[count[]] -[[1]]">
different {{Certificate-not.svg}}
</$list>
<$wikify name=this-wiki text="<<currentWiki>>">
<$list filter="[<this-wiki>] [{!!wiki-owner}] +[count[]] -[[2]]">
same {{Certificate.svg}}
</$list>
<$list filter="[<this-wiki>] [{!!wiki-owner}] +[count[]] -[[1]]">
different {{Certificate-not.svg}}
</$list>
</$wikify>
I believe it was not until I used wikify to create a variableThe Following example does not work even although <<currentWiki>> returns the correct value
\define currentWiki() {{$:/PSaT/wikimanager/wiki-tiddler##wiki-title}}
<<currentWiki>>
<$list filter="[<currentWiki>] [{!!wiki-owner}] +[count[]] -[[2]]">
same {{Certificate.svg}}
</$list>
<$list filter="[<currentWiki>] [{!!wiki-owner}] +[count[]] -[[1]]">
different {{Certificate-not.svg}}
</$list>How ever when refactored this works
<$wikify name=this-wiki text="<<currentWiki>>”>
<$list filter="[<this-wiki>] [{!!wiki-owner}] +[count[]] -[[2]]">
same {{Certificate.svg}}
</$list>
<$list filter="[<this-wiki>] [{!!wiki-owner}] +[count[]] -[[1]]">
different {{Certificate-not.svg}}
</$list>
</$wikify>I stand to be corrected, but that is all I can say at this point.RegardsTony
On Wednesday, November 7, 2018 at 5:03:21 PM UTC+11, Mohammad wrote:Hello Tony!
This is really interesting! I would appreciate if you could put it inside a wiki and give link for future references!By the way you said the variables cannot be the result of a macro call, why?-Mohammad
--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/962c78fe-6e3d-4860-a2c3-daeba7aeca98%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Can we establish a "best practice" approach such that when creating a macro to return a value in the first place, say we use the text widget to create "clean" value for use in filters to avoid this kind of issue.
In my use case, I retrieved a value from a data tiddler to set a variable currentWiki, I made this a global macro so I could refer to <<currentWiki>> whenever I needed it. Perhaps I should have used the text widget to ensure this value was already plain text.
Alternativly could filters themself be improved to clean variables before use, or would this have undesirable consequences?
Regards
Tony
I am trying to make a simply comparison between two variables or one variable and a fields content.eg; <<currentWiki>> and {{!!wiki-owner}}or <<currentWiki>> and <<wiki-owner>>I simply want a simple test or filter that will be true if they are the sameand that will be false if they are the same
<$reveal type="match" state="$:/state/SampleReveal1" text="show">
show this if state tiddler content matches text param
</$reveal>
<$reveal type="match" default={{somefield!!sometiddler}} text="show">
show this if some field in some tiddler matches text param
</$reveal>
or
<$reveal type="match" default=<<somevariable>> text="show">
show this if somevariable matches text param
</$reveal>
<$reveal type="match" default=<<somevariable>> text=<<someOtherVariable>>>
show this if somevariable value matches someOtherVariable
</$reveal>
<$set name="todo" filter="[tag[todo]count[]]">
<$set name="done" filter="[tag[done]count[]]">
<$reveal type="match" default=<<todo>> text="0"> There is nothing to do. </$reveal>
<$reveal type="nomatch" default=<<todo>> text="0">
<$reveal type="match" default=<<done>> text="0"> You haven't started. </$reveal>
<$reveal type="LT" default=<<todo>> text=<<done>>> You're making progress... keep going! </$reveal>
<$reveal type="match" default=<<todo>> text=<<done>>> You're half way there... take a short break </$reveal>
<$reveal type="GT" default=<<todo>> text=<<done>>> You've done a lot... but there's still some left </$reveal>
</$reveal>
</$set>
</$set>
https://tid.li/tw5/hacks.html#ifAisB%20%E2%80%93%20Compare%20if-then-else%20Style%20in%20Wikitext
All the best,
Thomas
Interesting, I have never heard it put this way.
You should only use <<currentWiki>> to render a global macro if you want the content of the macro to be wikified.
I need to think about that. If a variable in the list widget, wikify or set widget is used they will also be wikified <<asavar>>?
If you look back to my example I solved the problem by using wikify, which seems to contradict the above. I am sure I am missing a subtle detail.
Thank
Tony
\define currentWiki() <$wikify name=wiki-name text="{{$:/PSaT/wikimanager/wiki-tiddler##wiki-title}}"><$text text=<<wiki-name>> /></$wikify>
<<currentWiki>>
<$list filter="[all[current]has[wiki-owner]]">
<$list filter="[<currentWiki>] [{!!wiki-owner}] +[count[]] -[[2]]">
{{Certificate.svg}}
</$list>
<$list filter="[<currentWiki>] [{!!wiki-owner}] +[count[]] -[[1]]">
{{Certificate-not.svg}}
</$list>
</$list>
<$reveal type="match" default={{!!wiki-owner}} text={{$:/PSaT/wikimanager/wiki-tiddler##wiki-title}}>
{{Certificate.svg}} Match
</$reveal>
<$reveal type="nomatch" default={{!!wiki-owner}} text={{$:/PSaT/wikimanager/wiki-tiddler##wiki-title}}>
{{Certificate-not.svg}} No Match
</$reveal>
but that would be nice to replace {{$:/PSaT/wikimanager/wiki-tiddler##wiki-title}} with <<currentWiki>> but it does not work
title: $:/PSaT/wikimanager/wiki-tiddler
type: application/x-tiddler-dictionary
wiki-title: mau
title: Compare lab
wiki-owner: mau
\define currentWiki() {{$:/PSaT/wikimanager/wiki-tiddler##wiki-title}}
----
!!currentWiki macro output
<<currentWiki>>
----
!!Using field reference
<$reveal type="match" default={{!!wiki-owner}} text={{$:/PSaT/wikimanager/wiki-tiddler##wiki-title}}>
Match
</$reveal>
<$reveal type="nomatch" default={{!!wiki-owner}} text={{$:/PSaT/wikimanager/wiki-tiddler##wiki-title}}>
No Match
</$reveal>
----
!!Using currentWiki macro
<$reveal type="match" default={{!!wiki-owner}} text=<<currentWiki>> >
Match
</$reveal>
<$reveal type="nomatch" default={{!!wiki-owner}} text=<<currentWiki>> >
No Match
</$reveal>
----
!!Using set widget
<$set name="currentWiki" value={{$:/PSaT/wikimanager/wiki-tiddler##wiki-title}}>
<$reveal type="match" default={{!!wiki-owner}} text=<<currentWiki>> >
Match
</$reveal>
<$reveal type="nomatch" default={{!!wiki-owner}} text=<<currentWiki>> >
No Match
</$reveal>
</$set>
----
!!Using set widget + currentWiki macro
<$set name="currentWiki" value=<<currentWiki>> >
<$reveal type="match" default={{!!wiki-owner}} text=<<currentWiki>> >
Match
</$reveal>
<$reveal type="nomatch" default={{!!wiki-owner}} text=<<currentWiki>> >
No Match
</$reveal>
</$set>