[tw5] Re: Filter operators: THEN ELSE ~(ELSE)

2019-12-04 Thread TonyM
Mohammad et al,

Also consider the use of getvariable Operator 

New in: 5.1.20 The usual way to retrieve a variable value within a filter 
is with the angle brackets notation. For example, [] will 
retrieve the value of the variable called currentTiddler.  

eg Untested by me just now

[] or [match[yes]] or [else[novalue]]

Also

is Operator 

New in: 5.1.20 is[variable]] test exists as a variable (whether or not that 
variable has a non-blank value)
blank New in: 5.1.20 is[blank] (i.e. is a zero length string)

Tony


On Thursday, December 5, 2019 at 1:51:20 AM UTC+11, Mohammad wrote:
>
> I am wondering how to use filter operator THEN, ELSE and ~(else)
>
> Why the below fails
>
> <$list filter="[thenelse]>
>
>
> 
>
>
> What is the difference between else and ~?
>
> <$list filter="[else]">
>
>
> 
>
>
> and 
>
> <$list filter="[[] ~[]]">
>
>
> 
>
>
> --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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/329c7aa6-b8e7-4c08-ada9-6c1eb1b6c7f6%40googlegroups.com.


Re: [tw5] Re: Filter operators: THEN ELSE ~(ELSE)

2019-12-04 Thread Xavier Cazin
Hi Mohammad,

A good concrete example could be a followup to your recent template
question. Here, we used the ~[...] construct to *compute* a tiddler title
(or a list thereof):

<$list variable=template filter="[tag[a]] ~[tag[b]] ~[[tid3]]">
<$transclude mode=block tiddler=<> />


The computation of tid2 could have been of course arbitrarily more complex
than *[tag[b]].*
If we wanted to use the *else* operator on the other hand, the only thing
we could have done would have been to directly write tiddler titles that
were previously known, like in:

<$list variable=template filter="[tag[a]else[tid2]else[tid3]]">
<$transclude mode=block tiddler=<> />


Or at most, got from a variable or a  field:

<$list variable=template
filter="[tag[a]elseelse{field-holding-tid3}]">
<$transclude mode=block tiddler=<> />


By the way, your test below is indeed intriguing. It looks like the
operator *title* (hidden in the  expression) always constructs something
that won't be considered empty by the rest of the filter, whatever the
value of the variable  is. In other words, it always returns b. It
sounds like a bug to me :-)

<$list filter="[thenelse]">




-- Xavier


On Wed, Dec 4, 2019 at 8:20 PM Mohammad  wrote:

> Yes, I hope to see more example to see how they work!
>
> --Mohammad
>
> On Wednesday, December 4, 2019 at 7:36:46 PM UTC+3:30, TiddlyTweeter wrote:
>>
>> Could you give a concrete example? Just asking for a friend :-)
>>
>> On Wednesday, 4 December 2019 16:49:18 UTC+1, PMario wrote:
>>>
>>> Hi,
>>>
>>> then and else are used in a filter run. ~ starts a new run.
>>>
>>> See the docs list
>>> 
>>> .
>>>
>>> -m
>>>
>>> --
> 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+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/tiddlywiki/8a4a3a6b-5050-416e-85f9-9f31bfb5b8c1%40googlegroups.com
> 
> .
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CADeSwYPLjYok%2BtFkFAWZP2y_r088gF%3DmbL0naYMp71gsXezTaA%40mail.gmail.com.


[tw5] Re: Filter operators: THEN ELSE ~(ELSE)

2019-12-04 Thread TonyM
I think the best way for me is to think of then and else operators is they 
return a string, or title if the list is not empty then or else if list is 
empty.


Generate/list titles > then[hastitles]else[notitles]

So the above coded as a filter will only ever return hastitles or notitles.

The ~ on the other hand does test for empty list as well and can return a 
single title or new list.

Along with match these new operators will allow us to write filters more 
logically and in more natural language, I would say plain English like but the 
titles can be any language. 

By being able to generate a string/title output on ones choosing from a filter, 
the wiki text can have further tests to respond to the generated result.

Happy to post examples as I collect them for myself.

Tony

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/c588fab3-09de-44a4-94ba-a353fa6fc038%40googlegroups.com.


[tw5] Re: Filter operators: THEN ELSE ~(ELSE)

2019-12-04 Thread Mohammad
Yes, I hope to see more example to see how they work!

--Mohammad

On Wednesday, December 4, 2019 at 7:36:46 PM UTC+3:30, TiddlyTweeter wrote:
>
> Could you give a concrete example? Just asking for a friend :-)
>
> On Wednesday, 4 December 2019 16:49:18 UTC+1, PMario wrote:
>>
>> Hi, 
>>
>> then and else are used in a filter run. ~ starts a new run. 
>>
>> See the docs list 
>> 
>> .
>>
>> -m
>>
>>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/8a4a3a6b-5050-416e-85f9-9f31bfb5b8c1%40googlegroups.com.


[tw5] Re: Filter operators: THEN ELSE ~(ELSE)

2019-12-04 Thread TiddlyTweeter
Could you give a concrete example? Just asking for a friend :-)

On Wednesday, 4 December 2019 16:49:18 UTC+1, PMario wrote:
>
> Hi, 
>
> then and else are used in a filter run. ~ starts a new run. 
>
> See the docs list 
> 
> .
>
> -m
>
>

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/a0691de1-be56-4d12-8c19-61b8c7a091c2%40googlegroups.com.


[tw5] Re: Filter operators: THEN ELSE ~(ELSE)

2019-12-04 Thread PMario
Hi, 

then and else are used in a filter run. ~ starts a new run. 

See the docs list 

.

-m

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/a19c26c7-61ec-4bb8-aeaf-f2fb38ca27fa%40googlegroups.com.


[tw5] Re: Filter operators: THEN ELSE ~(ELSE)

2019-12-04 Thread Eric Shulman
On Wednesday, December 4, 2019 at 6:51:20 AM UTC-8, Mohammad wrote:
>
> I am wondering how to use filter operator THEN, ELSE and ~(else)
> Why the below fails
> <$list filter="[thenelse]>
>

not sure.  gotta think about this a bit... 

What is the difference between else and ~?
> <$list filter="[else]">
> and 
> <$list filter="[[] ~[]]">
>
 
The big difference here is that else[...] can only substitute a single 
value, while ~[...] can be a complex filter expression

-e

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/3d68f6a8-1fca-40fe-b3d3-05c0bf48e3e7%40googlegroups.com.