Why Concatenate and how?

201 views
Skip to first unread message

TonyM

unread,
Feb 26, 2019, 12:17:09 AM2/26/19
to TiddlyWiki
I think a lot of people intentionally or unintentionally try and concatenate or join together text and Tiddlywiki values, and this often causes grief.

As a result of a "discord discussion" I realised on of the common reasons has its own "concatenation tool" the Qualify Macro (see below)

However this prompts me to ask the community, Why would you use concatenation?
  • This will help us identify how to document this sometimes tricky aspect of TiddlyWiki
  • Please post in this thread any reasons you need to concatenate, and it will inform the documentation.
Thanks in advance
Tony


The Qualify Macro

eg One common use is to generate a tiddler name to use as a state field that includes the current tiddler name.

The Qualify macro provides a short cut for this <<qualify $:/state/tiddler>> will generate a title such as $:/state/tiddler--1383354177
The number is a hash of the currentTiddler title and can be regenerated
eg with the same "currentTiddler" <<qualify $:/temp/state>> will generate $:/temp/state--1383354177

A Quick note on concatenation  
Should a search bring you to this thread.

Many of you will realise your instinct to try and concatenate more than one value will not work. Here we explain how to do this.

For example value="<<variableormacro>>{{transclusion}}Text" used in a widget parameter including with the $macrocall widget, does not work.
  • In this case you can see that the value="a literal unevaluated version" so it will return precisely <<variableormacro>>{{transclusion}}Text which is unlikely what you intended.
Also consider value=<<variableormacro>>{{transclusion}} used in a widget parameter including with the $macrocall widget, does not work either.
  • Another way to look at it is as value=<<variableormacro>> and value={{transclusion}} works the << >> and {{ }} are acting to delineate the beginning and end of the value, combining them is like providing more than one beginning and end to the value and causes errors.
use the following methods to concatenate a number of values after first evaluating them

With the Wikify widget

<$wikify name=varname text="<<variableormacro>>{{transclusion}}Text">
 <
<varname>> valid until wikify closed
</$wikify>


Concatenating Within Macro definitions

\define varname() <<variableormacro>>{{transclusion}}Text
Remember here the following also work Within Macro definitions (only)
$parametername$
$
(externalvariable)$
Note the values differentiated by "$" signs are substituted before being evaluated so examples such as [[$parametername$]] should work

Concatenating Within Filters
    • addprefix, add suffix and more
    • More info to follow


Mohammad

unread,
Feb 26, 2019, 4:52:01 AM2/26/19
to TiddlyWiki
Hi Tony,
 Thank you for bringing this issue up! As you told many have this problem and one the AREA!!! of Q&A in this forum is concatenation.

By the way I would add a short comment here, the new String Operators has a concatenate operator!
I think it worth to be discussed here.

For me the concatenation normally required when a variable and wikitext should be used to create a new value or a string and variable/transculated value need to be concatenated.

I use addprefix, addsuffix quite alot and they do some concatenation!

It is good to make a search in Tiddler-Commander and see some Q&A.

--Mohammad

Reply all
Reply to author
Forward
0 new messages