Eric,

Thank you for your reply, especially for the comments on how it works. And, 
it works perfectly.

And, I got to learn several new things as a result. Defering variable 
definition until button press was what I was needing, but wasn't aware of 
using actions. Thank you much, good sir.

My best,

Mark


On Friday, July 31, 2020 at 5:35:09 PM UTC-4, Eric Shulman wrote:
>
> On Friday, July 31, 2020 at 12:41:19 PM UTC-7, Mark Hylton wrote:
>>
>> How do I programmatically build a string to be used as the title for a 
>> new tiddler (<$button> ... $message="tm-new-tiddler" ... title=???)?
>> I'm trying to use <$button> to start a new tiddler, but I can't get the 
>> title set the way I wish. What I want the new tiddler title to be (for 
>> instance) is "*A1234,Risk (2020-07-27 15:00:00): *", where:
>>
>
> Here's my solution:
> \define newRisk_button() <$button actions=<<newRisk_actions>>> New 
> project risk entry </$button>
>
> \define newRisk_actions()
> <$vars
>    projnum={{{ [<storyTiddler>get[projectnumber]] }}}
>    time=<<now "YYYY-0MM-0DD 0hh:0mm:0ss">>
> >
> <$action-sendmessage $message="tm-new-tiddler"
>    title={{{ [<projnum>addsuffix[,Risk (]addsuffix<time>addsuffix[)]] }}}
>    tags={{{ [<projnum>addsuffix[ risk]] }}}
>    text={{creationtemplateRisk}}
>    projectnumber=<<projnum>>
> />
> </$vars>
> \end
>
> Need to document a new project risk?
> Click this button: <<newRisk_button>> to create a new risk tiddler with 
> this [[template|creationtemplateRisk]]
> and tagged with <$macrocall $name="tag" tag={{{ 
> [<storyTiddler>get[projectnumber]] }}} /> and <<tag risk>>
>
> Notes:
> * newRisk_button() macro outputs a $button widget (note the *single-line* 
> macro definition omits the \end)
> * $button uses the actions="..." parameter to defer all button processing 
> until the button is pressed
> * this allows the <<now>> macro below to get the current datetime value at 
> the time the button is pressed
>
> * newRisk_actions() macro is invoked when the $button is pressed
> * $vars uses an inline filter to get the projnum value from the current 
> storyTiddler's "projectnumber" field
> * it also get the current datetime value using the <<now>> macro
> * $action-sendmessage triggers tm-new-tiddler to create a new tiddler
> * the title param uses an inline filter to construct the new title from 
> the projnum and datetime
> * the tags param uses an inline filter to construct the new tags from the 
> projnum and "risk"
> * the text param fetches the template contents
> * the projectnumber param adds a field with the value of the projnum
>
> Then:
> the text of the tiddler shows the newRisk_button and a link to the template
> along with "tag pills" for the current storyTiddler's project number and 
> the "risk" tag.
>
> enjoy,
> -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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/7a621b6a-4fe4-46a2-a0fd-02d7045f5c2bo%40googlegroups.com.

Reply via email to