Concatenate this...

126 views
Skip to first unread message

MagoArcade

unread,
Jul 22, 2019, 5:42:48 AM7/22/19
to TiddlyWiki
Ok - so I'm trying to use a concatenated string as a field value in a new tiddler. Existing code:

<$action-sendmessage $message="tm-new-tiddler" $param="_templateTask" title={{$:/_opTaskStore!!taskname}} shorttext={{$:/_opTaskStore!!description}} tmap.id={{{ [[]make[%uuid%]] }}} assignedto={{$:/_opTaskStore!!assignedto}} caption={{$:/_opTaskStore!!description}} tags="[[Task]]" color={{$:/_opTaskStore!!color}} />

I'm waning "title" to be a concatenation of two values:

{{$:/_opTaskStore!!taskname}}

and 

{{{ [[]make[%uuid%]] }}}

also with some formatting. Pseudo code:

final = {{$:/_opTaskStore!!taskname}} + " (" + {{{ [[]make[%uuid%]] }}} + ")"

making final code looking something like:

<$action-sendmessage $message="tm-new-tiddler" $param="_templateTask" title=<<final>> shorttext={{$:/_opTaskStore!!description}} tmap.id={{{ [[]make[%uuid%]] }}} assignedto={{$:/_opTaskStore!!assignedto}} caption={{$:/_opTaskStore!!description}} tags="[[Task]]" color={{$:/_opTaskStore!!color}} />

How can I achieve this (btw - my head's shot with macros/variables/brackets - in short - I feel I've tried everything and short of giving infinite monkeys infinite typewriters...)


it does return in a funny format (italicised link in wikiview)

Thanks all for your ongoing help to this newbie. 

Watt

unread,
Jul 22, 2019, 6:22:04 AM7/22/19
to TiddlyWiki
You're in the right direction but I think you have to define the concatenation as a local macro at the top of the edit area put this;

\define final()
{{$:/_opTaskStore!!taskname}} - ({{{ [[]make[%uuid%]] }}})
\end

And then call it where you need it with;

<<final>>

The uuid part may give problems. Sometimes it's necessary to wikify a calculation to render it correctly. If so define final as above then put

<$wikify name="myfinal" text=<<final>> >

Your code here.

</$wikify>

Hope that works, somebody will correct me if not I hope. Lie down in a darkened room and get your strength up before you look up wikify in the docs!

Watt

unread,
Jul 22, 2019, 6:24:19 AM7/22/19
to TiddlyWiki
Ps and call it as <<myfinal>> if wikified.

MagoArcade

unread,
Jul 22, 2019, 6:55:25 AM7/22/19
to TiddlyWiki
Bang! You got it - thanks again - I owe a few people around here a few beers.

Coding this beast's a dark art - does it get any easier?? First language I learned a few years ago was batch + I thought that was difficult! 

Watt

unread,
Jul 22, 2019, 7:17:14 AM7/22/19
to TiddlyWiki
In my experience no, it doesn't get any easier, but I'm an infinity monkey and enjoy this as a break from Shakespeare's complete works.

MagoArcade

unread,
Jul 22, 2019, 7:25:37 AM7/22/19
to TiddlyWiki
ha! Good answer.

Mat

unread,
Jul 22, 2019, 8:21:02 AM7/22/19
to TiddlyWiki
Yes, rule of thumb: "Concatenation ---> macro"

You can sometimes do things like 

filter="$foo$ +[addsuffix[...]]"

<:-)

TonyM

unread,
Jul 22, 2019, 10:31:38 AM7/22/19
to TiddlyWiki
It does get easier. This is one of the tricker lessons. The problem is we become used to using replaceable parameters everywhere and find it hard when we can't.

I expect you need to learn this youself, but this is how I see it.

Concatenating can be necessary when there is no practical way left to delineate replaceable parameters to form a new parameter. This is not so obvious because tiddlywiki goes out of its way reduce the need for delimiters by using those already available to it.

Although there are exceptions, one way to look at it is when you are passing a macro or widget a parameter, you need to delimit the beginning and end of the value eg parm="value" parm=<<varname>> parm={{!!title}} these will be replaced if simple but you should not expect compound values, ie concatination to be "evaluated" eg; parm={{!!title}}/subtiddlers because you are assuming this will occur before it is used as the parm value.

A simple rule is don't try and do too much in your parameters to a macro or widget. Keep the values to parameters simple in the widget and when concatenation is required do it before such as the example given. Define the concatenation elsewhere and reference that and macros are the most versatile. Wikifi and the Tripple braces and Evans mushroom brackets (= something evaluated =) are kind of exceptions but wikify is also a widget and only its text field is special by definition.

Unlike set and wikify, macro definitions do not need opening and closing so they are often the best way to concatenate, unless you can do it inside a filter in cases where the macro or widget accepts a filter.

I expect with the new filter string operators in 5.1.20 we will all start using the triple braces a lot more for this.

Eg

parm={{{ [{!!title}addsuffix[/subtiddlers]] }}}

Regards
Tony

MagoArcade

unread,
Jul 22, 2019, 11:38:37 AM7/22/19
to TiddlyWiki
Thanks Tony. TiddlyWiki is some kinda black-magic, 4th dimension, voodoo insane genius (meta upon meta - kinda a cross between OOP, procedural + the self-modifying code part of assembly)!

parm={{{ [{!!title}addsuffix[/subtiddlers]] }}}

I do wonder if Jeremy should introduce a few more brackets, though. It's evidently how his mind works! I blame those BBC micros - he should have bought himself a C64. 
 

Mohammad

unread,
Jul 22, 2019, 12:35:52 PM7/22/19
to TiddlyWiki
You are right MagoArcade,
 For a person like you which get used to OOP or procedural programming the TW learning cure is not steep at all and it will take times to see how it works!
By the way you can do one thing in many ways in TW and this huge diversity causes a big confusion!

I love TW because it is like logo! I can make many things with it! But when you go deeper and want to develop code, and so on ... you see it is quite tricky!

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