Which tiddler is newer: What goes wrong here with Wikify

65 views
Skip to first unread message

Mohammad

unread,
Mar 14, 2019, 12:12:19 PM3/14/19
to TiddlyWiki
Create two tiddlers in tiddlywiki.com titled Aa and Bb

Now create a tiddler with below code inside it. This code compares the modified date of two tiddlers and shows yes
if Aa is newer than Bb and vice versa!

\define gt() 
$(TidA)$ $(TidB)$ +[nsort[]last[1]remove[$(TidB)$]]
\end

\define is-it-newer(TiddlerA, TiddlerB)
<$set name=TidA  tiddler=<<__TiddlerA__>> field="modified">
<$set name=TidB  tiddler=<<__TiddlerB__>> field="modified">
<$list filter=<<gt>> emptyMessage="no">
yes
</$list>
</$set>
</$set>
\end

> <<is-it-newer Aa Bb>>

> <$wikify text=<<is-it-newer Aa Bb>>  name=result>
<<result>>
</$wikify>

You will get different results

yes
no

Why the wikify shows the wrong result?

--Mohammad

BurningTreeC

unread,
Mar 14, 2019, 1:13:58 PM3/14/19
to TiddlyWiki
I assume it wikifies the macrocall itself before the macros are "executed"/"rendered"

There's a difference between wikify text=<<macro>> and wikify text="<<macro>>"

Jeremy Ruston

unread,
Mar 14, 2019, 1:28:30 PM3/14/19
to tiddl...@googlegroups.com
Hi Mohammad

When I run your sample I get the same results for both (see below).

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 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/fc215b27-126d-4bde-a942-30daa70acd26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mohammad

unread,
Mar 14, 2019, 1:41:41 PM3/14/19
to TiddlyWiki
Hi Jeremy,
 Have you created also the two tiddlers Aa and Bb?

I think if you have created these tiddlers you will see different results!

--Mohammad

Mohammad

unread,
Mar 14, 2019, 1:44:28 PM3/14/19
to tiddl...@googlegroups.com
Hi BTC,
 Thanks it works! but then if I further use the result I go into another trouble.

Now check this!

<$wikify text="""<<is-it-newer Aa Bb>>"""  name="result">
<<result>>
<$reveal type="match" text="yes" default=<<result>> >
Yes, Aa is newer
</$reveal>
<$reveal type="match" text="no" default=<<result>> >
No, Aa is older
</$reveal>
</$wikify>

No output! 

--Mohammad

BurningTreeC

unread,
Mar 14, 2019, 1:50:45 PM3/14/19
to TiddlyWiki
Hi BTC,
 Thanks it works! but then if I further use the result I go into another trouble.

No check this!

<$wikify text="""<<is-it-newer Aa Bb>>"""  name="result">
<<result>>
<$reveal type="match" text="yes" default=<<result>> >
Yes, Aa is newer
</$reveal>
<$reveal type="match" text="no" default=<<result>> >
No, Aa is older
</$reveal>
</$wikify>

No output! 



does the <<result>> show something? if it does the problem may just be the reveal widget ... does it really work without a state tiddler?

Mohammad

unread,
Mar 14, 2019, 1:54:34 PM3/14/19
to TiddlyWiki
Yes, result has a value: yes

Seems I cannot get any output from reveal widget!

I pasted the whole code here to be able to check in tiddlywiki.com!


\define gt() 
$(TidA)$ $(TidB)$ +[nsort[]last[1]remove[$(TidB)$]]
\end

\define is-it-newer(TiddlerA, TiddlerB)
<$set name=TidA  tiddler=<<__TiddlerA__>> field="modified">
<$set name=TidB  tiddler=<<__TiddlerB__>> field="modified">
<$list filter=<<gt>> emptyMessage="no">
yes
</$list>
</$set>
</$set>
\end

> <<is-it-newer Aa Bb>>

<$wikify text="""<<is-it-newer Aa Bb>>"""  name="result">
<<result>>
<$reveal type="match" text="yes" default=<<result>> >
Yes, Aa is newer
</$reveal>
<$reveal type="match" text="no" default=<<result>> >
No, Aa is older
</$reveal>
</$wikify>

BurningTreeC

unread,
Mar 14, 2019, 2:02:19 PM3/14/19
to TiddlyWiki
:) cool! the reveal widget seems to work used like this, I didn't know that

the problem seems to be that your "yes" and "no" results contain whitespace... you can just put a \whitespace trim within the is-it-newer macro

Mohammad Rahmani

unread,
Mar 14, 2019, 2:20:44 PM3/14/19
to tiddl...@googlegroups.com
BTC,
 Thank you, now it works and reveal widget shows the correct output!
It is difficult to debug the TW scripts! Seem only experiences help here!

A million thanks

Cheers
Mohammad


Best wishes
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.

Mohammad Rahmani

unread,
Mar 14, 2019, 2:21:26 PM3/14/19
to tiddl...@googlegroups.com
Added to TW-Scripts.


Best wishes
Mohammad


On Thu, Mar 14, 2019 at 9:32 PM BurningTreeC <hypnotize...@gmail.com> wrote:
--

BurningTreeC

unread,
Mar 14, 2019, 2:21:48 PM3/14/19
to TiddlyWiki
@Mohammad, 

using the wikify widget for this usecase seems to be useless, this can easily done without:

<$set name="tidBMod" value={{{ [[Bb]get[modified]] }}}>
<$set name="tidAMod" value={{{ [[Aa]get[modified]] }}}>
<$reveal type="match" text="yes" default={{{ [<tidAMod>] [<tidBMod>] +[nsort[]last[1]remove<tidBMod>addprefix[yes]removesuffix<tidAMod>] ~[[no]] }}}>
Yes, Aa is newer
</$reveal>
<$reveal type="match" text="no" default={{{ [<tidAMod>] [<tidBMod>] +[nsort[]last[1]remove<tidBMod>addprefix[yes]removesuffix<tidAMod>] ~[[no]] }}}>
No, Aa is older
</$reveal>
</$set>
</$set>


BurningTreeC

unread,
Mar 14, 2019, 2:27:09 PM3/14/19
to TiddlyWiki
BTC,
 Thank you, now it works and reveal widget shows the correct output!
It is difficult to debug the TW scripts! Seem only experiences help here!

I must say you're also making it difficult by using the wikify widget

Mohammad

unread,
Mar 14, 2019, 2:28:44 PM3/14/19
to TiddlyWiki
A smart solution!

Much shorter and semantic!

Thanks alot!

Added to TW-Scripts


--Mohammad

BurningTreeC

unread,
Mar 14, 2019, 2:33:51 PM3/14/19
to TiddlyWiki
A smart solution!

Much shorter and semantic!

Thanks alot!

Added to TW-Scripts


What I want to say is that I think the wikify widget should never be the widget of choice if it can be done without

When I use it I try questioning if there's a reason why, if I know that it does something that's not possible or more difficult without it

BurningTreeC

unread,
Mar 14, 2019, 2:40:01 PM3/14/19
to TiddlyWiki
A smart solution!

Much shorter and semantic!

It still can be shortified:

<$set name="tidBMod" value={{{ [[Bb]get[modified]] }}}>
<$set name="tidAMod" value={{{ [[Aa]get[modified]] }}}>
<$list filter="[<tidAMod>] [<tidBMod>] +[nsort[]last[1]removesuffix<tidAMod>]">
Yes, Aa is newer
</$list>
<$list filter="[<tidAMod>] [<tidBMod>] +[nsort[]last[1]removesuffix<tidBMod>]">
No, Aa is older
</$list>
</$set>
</$set>


Mohammad

unread,
Mar 14, 2019, 2:52:46 PM3/14/19
to TiddlyWiki
That's true! In my case I use wikify widget when I have to use the result of a macro or want to store a variable.
I also use some general purpose macros and do not want to repeat the scripting!

--Mohammad

Mohammad

unread,
Mar 14, 2019, 2:55:42 PM3/14/19
to TiddlyWiki
Yes, This is shorter and even better!
list widget can do amazing things! while reveal  may be semantic in this case!

--Mohammad
Reply all
Reply to author
Forward
0 new messages