Macro currentTiddler parameter by default

Newby and non english spoken question !!! thanks for your patience

global mymacro :
\define mymacro param1: “the current Tiddler by default”
…\end

in each thistiddler :
mymacro thistiddler works
mymacro don’t work

why ?
How write the name of current Tiddler as parameter1 by default ? I try << {{ {{< …

Must write two macros ?

  1. define mymacro1( tiddlerparam) : I can use {{$tiddlerparam$!!fieldA}} and i can use myothermacro $tiddlerparam$
  2. define mymacro2() : use {{!!fieldA}}
    but I can’t use myothermacro

Perplixity or my web search give me wrong solution, outdated solution, too complex solutions…
Yet this is the first script we are trying to make when we enter in TiddlyWiki!

Thanks !

Try this:

\define mymacro(param1:<<currentTiddler>>)
PARAM1 = <<__param1__>>
\end

<<mymacro>>

<<mymacro "something">>

-e

Thanks for your answer.
Your solution doesn’t work in a table. Please try in a tiddler :
(I put there all the possible)

\define Dim(t:<<currentTiddler>>)
r=<<__t__>>

| table |k
| n  | colA | colB |
| 1 | {{t!!Unicité}}  |  t   |
| 2 | {{r!!Unicité}} |    r    |
| 3 |  {{<<__t__>>!!Unicité}}  |  <<__t__>>  |
| 4 | {{$t$!!Unicité}} | $t$   |
| 5  |{{$r$!!Unicité}} |  $r$    |
\end

<<Dim>>
<<Dim Unicité>>


NB I add spaces for wrtitting
[CODE BLOCK FORMATTED BY SPRINGER — feel free to edit @paulTW]

Your solution doesn’t work in a table
Only command 2 line 4 works
Thanks for your help

Paul, tu peux inclure des blocs de code dans tes messages en les encadrant par une ligne qui contient uniquement trois “backticks” à la suite, comme dans tiddlywiki.

Exemple:

```
Mon code
```

donne ce résultat :

Mon code

Fred

to share wikitext, you can use this: Share — tools to share tiddlers via URLs

It’s easier to help you that way

@paulTW here are 3 working solutions for you to choose from:

\define Dim(t:<<currentTiddler>>)
<$wikify name="r" text=<<__t__>>>

| table |k
| n  | colA | colB |
| 6  |<$text text={{{[<r>get[Unicité]]}}}/> |  <<r>>    |
</$wikify>
\end

\define Dim2(t:"")
<$let r={{{[[$t$]!is[blank]else<currentTiddler>]}}}>

| table |k
| n  | colA | colB |
| 6  |<$text text={{{[<r>get[Unicité]]}}}/> |  <<r>>    |
</$let>
\end

\procedure Dim3()
\function get.Unicité() [<t>get[Unicité]]
<$parameters t=<<currentTiddler>>>

| table |k
| n  | colA | colB |
| 6  |<<get.Unicité>> |  <<t>>    |
</$parameters>
\end

<<Dim>>
<<Dim Unicité>>

---

<<Dim2>>
<<Dim2 Unicité>>
---

<<Dim3>>
<<Dim3 Unicité>>

If you’re using latest TiddlyWiki version, I would recommend the Dim3 procedure+function version.

Fred

Try this:

\define Dim(t:<<currentTiddler>>)
<$tiddler tiddler=<<__t__>>>
...

This will set the currentTiddler within the macro to whatever you’ve passed in. Then, you can use just the field reference – {{!!Unicité}} – without needing to explicitly provide the tiddler title.

Alternatively, rather than using the {{!!fieldname}} transclusion “short form” syntax, you could use a full $transclude widget, like this: <$transclude $tiddler=<<__t__>> $field="Unicité"/>

or, you could use a “filtered transclusion”, like this: <$text text={{{ [<__t__>get[Unicité]] }}}/>. Note the use of the $text widget which causes the filtered transclusion result to be rendered as plain text instead of a link to the displayed field value.

-e