Syntax Q: Use procedure in a filter

So I have a procedure that requires an argument that is a variable (e.g <<currentTiddler>>) when called. I want to use the procedures output in a filter. How do I do this syntactically, i.e how do I get the argument into the procedure in the following?

\procedure one(myvariable) <<myvariable>>

{{{ [<one>match[bar]then[foobar]] }}}

…and same problem, I think if I tro to externalize it…

<$set name=procoutput value=??? >
{{{ [<procoutput>match[bar]then[foobar]] }}}
</$set>

It feels like this is something for parametrised transclusions but I can’t wrap my head around how to actually do it.

Help appreciated!

The best approach will depend on the contents of your procedure, but if it’s only intended to store a single variable or output a simple string of text, this is a perfect scenario for a function instead.

\function one(myvariable) [<myvariable>]

Call it like this: {{{ [function[one],<currentTiddler>match[bar]then[foobar]] }}}

The first argument of function is the name of the function to use; each additional argument defines a parameter of that function, assigned in the order that you defined them in the function. Each parameter (including the name of the function itself!) can be [text], a <variable>, or a {!!transclusion}.

Or if you use at least one . in the function name, you can use it as an ad-hoc filter operator.

\function .one(myvariable) [<myvariable>]

Call it like this: {{{ [.one<currentTiddler>match[bar]then[foobar]] }}}

Or like this: {{{ [function[.one],<currentTiddler>match[bar]then[foobar]] }}}

If your procedure is anything more complicated than a variable or a filter… I’m afraid you’re going to have to $wikify it as a separate step before you use it in a filter, sorry.

1 Like

@etardiff - I appreciate your kind reply but, alas, it is indeed more complicated than a variable or filter. And I dont get the wikifywidget to work for it either. I might post the full thing in a bit. Again, thank you.

There is very little a filter, thus a function can’t do including variables, it also has the advantage that it need not be wikified nor does it require the text widget.

I can give more assistance if you want to take this approach, which I recommend. (

  • This includes using +[join[ ]] or +[format:titlelist[]join[ ]] to allow more than the first value be returned.

Thanks @TW_Tones - the real question for this matter is elaborated on in this question: Variable as argument when it, itself, requires a variable argument

I’d very much welcome any help for that matter because I stumble on it from time to time.

Again, thanks.