[TW5] Has and Has not got a field ?

96 views
Skip to first unread message

TonyM

unread,
Dec 31, 2017, 11:03:54 PM12/31/17
to TiddlyWiki

Folks,

Can anyone tell me why I am seeing both the + and the - Button here, and why the "has" and "!has" is not working?

\define fieldnames()
<$list filter="[list[!!fieldnames]]" variable=eachfield>
   
<$list filter="[is[current]!has[<eachfield>]]" variable=null>
     
<$button>
         
<$action-setfield $field=<<eachfield>> $value=" "/>
         
+
     
</$button>
   </
$list>
   
<$list filter="[is[current]has[<eachfield>]]" variable=null>
     
<$button>
         
<$action-deletefield $field=<<eachfield>>/>
         -
      </
$button>
   
</$list>
   <<eachfield>>
</
$list>
\end

Sadly I have spent some time trying to debug it with no success.

Ideas welcome.

Thanks in advance
Tony

Eric Shulman

unread,
Jan 1, 2018, 1:05:18 AM1/1/18
to TiddlyWiki
On Sunday, December 31, 2017 at 8:03:54 PM UTC-8, TonyM wrote:
Can anyone tell me why I am seeing both the + and the - Button here, and why the "has" and "!has" is not working?
\define fieldnames()
<$list filter="[list[!!fieldnames]]" variable=eachfield>
   
<$list filter="[is[current]!has[<eachfield>]]" variable=null>
...
 
   </$list>
   
<$list filter="[is[current]has[<eachfield>]]" variable=null>
...

Your filter syntax is incorrect.  The brackets are used to indicate the type of operand.... square brackets surround literal values, curly braces around field references, and angle brackets around variable names.  Thus, omit the extra square brackets and just use the angle brackets, like this:

<$list filter="[is[current]!has<eachfield>]" variable=null>
and
<$list filter="[is[current]has<eachfield>]" variable=null>

enjoy,
-e
Eric Shulman
TiddlyTools.com: "Small Tools for Big Ideas!" (tm)
InsideTiddlyWiki: The Missing Manuals




TonyM

unread,
Jan 1, 2018, 1:46:12 AM1/1/18
to TiddlyWiki
Thanks Eric,

I have made this mistake before, thinking I had, as you suggested in another example, but I clearly did not.
It is working nicely now thank you

Tony

Mal

unread,
Jan 1, 2018, 2:58:15 AM1/1/18
to TiddlyWiki
Eric,

Just to get this clear in my mind:

You indicated that the square brackets in filter expressions contain literal values.  How does this relate to the "is[current]" term?  Would you consider the tiddler category "current" is a literal?

Thanks,

Mal

TonyM

unread,
Jan 1, 2018, 3:27:19 AM1/1/18
to TiddlyWiki
Mal,

As I see it.

In this context current is a litteral that was placed into the filter unlike <name> which will be replaced before evaluating the filter.

I understand that is current becomes the current tiddler makes it look less like a litteral but in the filter string between the quotes it is litteral.

Regards
Tony

Eric Shulman

unread,
Jan 1, 2018, 4:04:23 AM1/1/18
to tiddl...@googlegroups.com
On Sunday, December 31, 2017 at 11:58:15 PM UTC-8, Mal wrote:
Just to get this clear in my mind:

You indicated that the square brackets in filter expressions contain literal values.  How does this relate to the "is[current]" term?  Would you consider the tiddler category "current" is a literal?

All the category operands for the is[...] filter are literal keywords that must be written exactly as specified in

current is the current tiddler
image has an image ContentType
missing does not exist (other than possibly as a shadow tiddler), regardless of whether there are any links to it
orphan has no hard links to it
shadow is a shadow tiddler, regardless of whether it has been overridden with a non-shadow tiddler
system is a system tiddler, i.e. its title starts with $:/
tag    is in use as a tag
tiddler exists as a non-shadow tiddler

Note that the "is" filter CAN accept TextReferences, using curly braces... or variable values using the angle brackets.  Thus:

<<list-links "[is{!!filterfield}]">>
or
<$vars filtervar={{!!filterfield}}">
<<list-links "[is
<filtervar>]">>
</$vars>
where "filterfield" is a field in the current tiddler whose value is one of the above listed literal keywords.

-e


Mal

unread,
Jan 1, 2018, 5:34:47 AM1/1/18
to TiddlyWiki
Tony and Eric,

Thanks for the clarifications.

I think I need to create my own summary of the rules for referencing in Tiddlywiki to make sure I have it firmly embedded in my brain.

Regards,

Mal

TonyM

unread,
Jan 1, 2018, 8:32:46 AM1/1/18
to TiddlyWiki
Eric

Is there any reason we can't have
Is[field] ?

I am currently building additional field handling which allows fields as Tiddlers just as we can have tags as Tiddlers.

I thought I saw some fields appearing after creation as system tiddlers somewhere but can't locate them again.

Regards
Tony

Reply all
Reply to author
Forward
0 new messages