is this a bug? empty index and is[blank] operator

57 views
Skip to first unread message

Mohammad

unread,
Mar 3, 2020, 9:05:18 AM3/3/20
to TiddlyWiki
  • In tiddlywiki.com create a  new tiddler titled as dataTid and set its type as application/json with below contents
{
   
"xx": "",
   
"yy": "hello"
}


  • in another tiddler issue the below command
<$list filter="[[dataTid]getindex[xx]is[blank]]" emptyMessage="the index is NOT blank">
The index is BLANK
</$list>

You get the wrong result. Why is[blank] does not detect the blank value of xx?


--Mohammad

Mark S.

unread,
Mar 3, 2020, 10:30:37 AM3/3/20
to TiddlyWiki
isblank operates on the output of the new split operator, which might be "mytitle" "" "someothertitle" "" etc.

So there has to be a "" to determine if it is blank.

Most filter operators do not produce "". If something is "", it puts out NO output -- not even ""

The operator getindex[xx] produces NO output, and so there is nothing to evaluate. You get the same result whether you don't use is[blank] .

So the upshot is, that is[blank] is mostly useful in the context of the split and splitreg operators.

Mohammad

unread,
Mar 4, 2020, 5:54:54 AM3/4/20
to TiddlyWiki
So,
 One should be very cautious to use is[blank]!

--Mohammad

Jeremy Ruston

unread,
Mar 4, 2020, 6:17:14 AM3/4/20
to TiddlyWiki
So,
 One should be very cautious to use is[blank]!

As Mark points out, the subtlety is that it checks for a zero length string, rather than checking for a missing result. I’m not sure “blank” was necessarily the best word to have chosen; we could always introduce an alias if there’s a clearer word for it.

Best wishes

Jeremy

-- 
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 view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/c7fc0f81-fc26-4ebf-8ef8-f12e84d37b1f%40googlegroups.com.

Mohammad

unread,
Mar 4, 2020, 6:48:26 AM3/4/20
to TiddlyWiki
Hi Jeremy
 Thanks for Clarification!

I assumed the below dataTiddler returns zero length string, but now I understood it idoes not! The value of xx is missing!

{
    
"xx": "",
    
"yy": "hello"
}


Best wishes
--Mohammad
To unsubscribe from this group and stop receiving emails from it, send an email to tiddl...@googlegroups.com.

Jeremy Ruston

unread,
Mar 4, 2020, 7:09:35 AM3/4/20
to TiddlyWiki
Hi Mohammad

I assumed the below dataTiddler returns zero length string, but now I understood it idoes not! The value of xx is missing!

Indeed, the getindex operator and the get operator both work that way, the great thing is that it lets you use the else[] operator to provide a fallback value:

[getindex[xx]else[defaultvalue]match[targetvalue]]

Best wishes

Jeremy

To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/ab836157-5364-484e-8a4c-26b7e4c55bb0%40googlegroups.com.

Mohammad

unread,
Mar 4, 2020, 7:43:27 AM3/4/20
to TiddlyWiki


On Wednesday, March 4, 2020 at 3:39:35 PM UTC+3:30, Jeremy Ruston wrote:
Hi Mohammad

I assumed the below dataTiddler returns zero length string, but now I understood it idoes not! The value of xx is missing!

Indeed, the getindex operator and the get operator both work that way, the great thing is that it lets you use the else[] operator to provide a fallback value:

[getindex[xx]else[defaultvalue]match[targetvalue]]

This is great, and I did not know that! 

Best wishes

Jeremy

Thanks for clarification

--Mohammad 

TonyM

unread,
Mar 4, 2020, 3:55:52 PM3/4/20
to TiddlyWiki
Jeremy,

Perhaps is[nul] ?

There were cases where stuffing a field with null or a single space rather than delete a field, technically these should be different
  • is[blank] = empty or one or more spaces
  • is[nul] = empty or a zero length string
I recall the mention of a logical high values and low values but can't find any references to them. I though they may be relevant to this.

Regards
Tony
To unsubscribe from this group and stop receiving emails from it, send an email to tiddl...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages