How can I get <<now>> to be evaluated now?

155 views
Skip to first unread message

Joe Armstrong

unread,
Jan 2, 2019, 12:28:34 PM1/2/19
to TiddlyWiki
I have made a tiddler called [[Log1]] this is
supposed to be a log file.


I have a second tiddler [[AddToLog]] which is supposed to add a time-stamped entry to the end of the log.

It has a little text box to enter text with and a button

AddToLog is like this:


    \define appendButton(old,add) 
       <$button set="Log1" setTo="$old$ <hr> At <<now>> <br> $add$"> add to log</$button> 
    \end 

     <$edit-text tiddler="$:/temp/Append"/> 
     <$macrocall $name="appendButton" old={{Log1}} add={{$:/temp/Append}}/>

If I run the code in this tiddler ut some text in the edit button and click
on 'add to log' the log gets appended with this:

   <hr> 
   At <<now>> <br> .. the text I entered ...

 Which is wrong since I want <<now>> to be now (ie something like 2019-01-02 ...) and NOT <<now>>

I have tried many ways to program my way around this but they all fail.

So how can I get the value of <<now>> now?

I need to turn off the lazy evaluation.

Cheers 

/Joe


Mark S.

unread,
Jan 2, 2019, 1:32:51 PM1/2/19
to TiddlyWiki
Wikitext doesn't get rendered between strings. The exception is wikitext inside of a wikify widget, which gets rendered sometimes on Wednesdays.

This worked in my test:

\define appendButton(old,add)
<$wikify name="stamp" text="$old$ <hr> At <<now>> <br> $add$">
       <$button set="Log1" setTo=<<stamp>>> add to log</$button>
</$wikify>
\end

HTH
-- Mark

Mohammad

unread,
Jan 2, 2019, 2:07:07 PM1/2/19
to TiddlyWiki
Hi Joe,

Ton Gerner has a very nice Time Stamp plugin, take a look




--Mohammad

Joe Armstrong

unread,
Jan 2, 2019, 2:32:06 PM1/2/19
to TiddlyWiki
UUm - this didn't work for me - the <hr> and <br> vanish without a trace
<<now>> is expanded correctly

?????

/Joe

Mark S.

unread,
Jan 2, 2019, 3:12:16 PM1/2/19
to TiddlyWiki
Try again:

\define stamp() $(old)$ <hr> At $(nows)$ <br> $(add)$
\define appendButton(old,add)
<$vars old="""$old$""" add="""$add$""" nows=<<now>>>

       
<$button set="Log1" setTo=<<stamp>>> add to log<
/$button>
</
$vars>
\end

-- Mark

TonyM

unread,
Jan 2, 2019, 6:24:48 PM1/2/19
to TiddlyWiki
Joe,

I already have a log here tool, that uses a data tiddler and timestamps each row/ record.

Would you like me to share it, or just the part that addresses the timestamping?

Tony

Mohammad

unread,
Jan 2, 2019, 11:01:05 PM1/2/19
to TiddlyWiki
Hi Mark,
 Just for curiosity: If I understand on each button click, TW reads the whole Log1 contents, stores it in an variable, appends new texts to it, and writes it back to the same tiddler.
Is there any way to not read and store Log1 content and just append texts to the end of tiddler? Is there any performance issue with the current solution?

--Mohammad

Mark S.

unread,
Jan 2, 2019, 11:34:19 PM1/2/19
to TiddlyWiki
Hi Mohammad,

A completely different approach would be to store the log entries in a data dictionary. Then use a display tiddler to present the entries. I have a daily reading log that works this way (I didn't write the routine -- think it was PMario) that now has records going back to 2014, so more than a thousand entries.

-- Mark

Mohammad

unread,
Jan 3, 2019, 12:14:04 AM1/3/19
to TiddlyWiki
Ah, Thank you Mark. That is the solution. A dictionary tiddler.

This way, no need to read the whole log into a variable and write back.
That way I can filter a period of time in my display tiddler.

You are great Mark. 

Cheers
Mohammad

TonyM

unread,
Jan 3, 2019, 12:41:58 AM1/3/19
to TiddlyWiki
Joe,

Here is my complete log solution. Attached, download and drag to your wiki,.

The viewTemplate tiddler determines when to display it, currently on non system tiddlers, and the $:/PSaT/macros/ShowLogMacro tiddler details the macros that come with it for use in different ways.

Eg list items logged here on this tiddler, or all tiddlers, recent only etc... or log line or text area.
.
It uses some tricks to combine the date time stamp, and current tiddler into a line in a data tiddler, the log is wikified so can include links etc... The list log functions reverse it to be most recent first.

Regards
Tony
Show-Log-Macro.bundle.json

Joe Armstrong

unread,
Jan 3, 2019, 3:21:12 AM1/3/19
to tiddl...@googlegroups.com
Brilliant - thanks a lot

/Joe

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/GATlu5BWzq8/unsubscribe.
To unsubscribe from this group and all its topics, 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/c112af20-a5f8-4c10-b51b-542c6506c064%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Joe Armstrong

unread,
Jan 3, 2019, 3:23:28 AM1/3/19
to tiddl...@googlegroups.com

That's amazing - lot's for me to study.

Cheers

/Joe

--
You received this message because you are subscribed to a topic in the Google Groups "TiddlyWiki" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/tiddlywiki/GATlu5BWzq8/unsubscribe.
To unsubscribe from this group and all its topics, 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.

PMario

unread,
Jan 3, 2019, 6:49:30 AM1/3/19
to TiddlyWiki
On Thursday, January 3, 2019 at 9:23:28 AM UTC+1, Joe Armstrong wrote:

That's amazing - lot's for me to study.

Hi Joe,

If you are interested in some UI howto's, I did create several videos, for a little project, that turned out to be more complex as it seemed at first.

I did create a bundle, that contains working code, so users can play with it. AND several videos, that describe the whole stuff "line by line" (almost :)


have fun!
mario

PMario

unread,
Jan 3, 2019, 7:20:47 AM1/3/19
to TiddlyWiki
On Thursday, January 3, 2019 at 5:34:19 AM UTC+1, Mark S. wrote:
...
A completely different approach would be to store the log entries in a data dictionary. Then use a display tiddler to present the entries. I have a daily reading log that works this way (I didn't write the routine -- think it was PMario) that now has records going back to 2014, so more than a thousand entries.

Hi Mark,

The only experiment I can remember was Jan. 2017. It is a "reading journal" experiment. ... The initial approach is a 2 click workflow, because TW couldn't handle an "open external link and create journal entry" action.

You mentioned your journals go back to 2014. ... Do you have a link to the code?

-m

Mark S.

unread,
Jan 3, 2019, 10:47:30 AM1/3/19
to TiddlyWiki
Hi PMario,

I may be attributing the wrong person. Tobias? Mans? But searching the forum and Dave's toolmap, I couldn't find it. Here's the code in it's entirety

\define saveSnapshot()
<$button set="$:/_snapshots##$(snapshot)$" setTo={{$:/StoryList!!list}}>Save Snapshot</$button>
\end

\define showSnapshot()
<$button set="$:/StoryList!!list" setTo={{$:/_snapshots##$(snap)$}}>Show Snapshot</$button>
\end

;Show Snapshot

<span title="Select a Snapshot"><$select tiddler="$:/_snapshots" field="story-name" default='(none)'>
<$list filter="[[$:/_snapshots]indexes[]]" variable="currentIndex">
<option value=<<currentIndex>>><<currentIndex>></option>
</$list>
</
$select></span>
<$set name="snap" value={{$:/_snapshots!!story-name}}>
<<showSnapshot>>
</
$set>

;Save Snapshot

<span title="Enter a Name"><$edit-text tiddler="$:/_snapshots" field="story-name"/></span>
<$set name="snapshot" value={{$:/_snapshots!!story-name}}>
<<saveSnapshot >>
</
$set>

-- Mark

Ton Gerner

unread,
Jan 3, 2019, 11:28:00 AM1/3/19
to TiddlyWiki

Mark S.

unread,
Jan 3, 2019, 12:32:27 PM1/3/19
to TiddlyWiki
Sorry to hear that he is the "late" Matabele. On groups like this people can disappear for many reasons and one never knows.

Thanks,
-- Mark

Ton Gerner

unread,
Jan 3, 2019, 1:52:18 PM1/3/19
to TiddlyWiki
Hi Mark,


On Thursday, January 3, 2019 at 6:32:27 PM UTC+1, Mark S. wrote:
Sorry to hear that he is the "late" Matabele. On groups like this people can disappear for many reasons and one never knows.

Mohammad

unread,
Jan 3, 2019, 1:52:25 PM1/3/19
to TiddlyWiki
Mark,

The snapshot solution actually belong to Metabele and further revised by Tobias Beer 


Cheers
Mohammad

Mohammad

unread,
Jan 3, 2019, 2:16:24 PM1/3/19
to tiddl...@googlegroups.com
Hi Ton,

This is a very sad news. Many of us use his great codes, but I and many others did not know he is passed away.

Rest in peace.

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