\procedure and lack of parameters if called by actions=

I am still struggling with \procedure. Having read docs and counsels here, I elaborated the following test code

\procedure track(bear:42)
<$let john = {{{ [[fellow $(bear)$ years old]substitute[]] }}}>
see <<bear>> and <<john>>
<$action-setfield done=<<john>> work=job old=<<bear>>/>
</$let>
\end

<<track 64>>. <<track>>

<$button actions=<<track 28>>>test 28</$button>

john: {{!!seen}}

screen output: " see 64 and fellow 64 years old . see 42 and fellow 42 years old"

This one is OK. This is because wikification has happened.

For the action on the button, there is no wikification. This should explain the problem. But how should I do? Why does a thing as simple as <<track 28>> is not working on actions?

So I once again went to look for the explanations. And I did find them in the recent topic I initiated Procedure argument default value - #18 by jypre

This is that "when you used a procedure as an attribute value (just as in `<$button actions=<<myproc 42>>`` then this procedure won’t have access to any argument!

This is rather sad, because it will have you define things like \define myarg() 42 in yor tiddler and use it within your myproc code. This is messy and very annoying, especially if you chain procedure calls. Let look at the following code to see what that means:

\procedure trail() <<track 16>>
\procedure track(bear:{{!!alt}})
\function age() [<bear>!is[blank]else{!!age}]
<$let john = {{{ [[fellow $(age)$ years old]substitute[]] }}}>
<$action-setfield done=<<john>> work=job old=<<bear>>/>
</$let>
\end

<<track 64>>. <<track>>
<$button actions=<<track>>>test trail</$button>

Clicking on the button change the value of the “done” field to “fellow 94 years old” and not “fellow 16 years old” even though it is not patent that we have called “track” as an attribute value.

Would it be possible to fix (yes, fix! that’s a bug, not a feature) this “no-arg-if-called-as-parameter” problem? Procedure should be a solution, not a well of problems. Having to use outside functions for what should have been parameters is a sure recipe to maintenance disaster because of a hard-to-follow code.

wouldn’t it be possible to hack a new \define with the featues pf current \define but without the possibility to use the $arg$ substitution but with the arg variable feature of the new \procedure? This new pragma should of course rretain the possibility to have arguments when called as attiribute value (directly or indirectly).This would be what \procedure should be IMHO.

I think you might have stumbled on a bug. I change it up to this:

\procedure track(bear:42)
<$let john = {{{ fellow [<bear>!is[blank]else[42]] years old +[join[ ]] }}}>
see <<bear>> and <<john>>
<$action-setfield done=<<john>> work=job old=<<bear>>/>
</$let>
\end

<<track 64>>. <<track>>

<$button actions=<<track 28>>>test 28</$button>

john: {{!!seen}}

And only then do I get the 42 to show up in done. Action parameters do wikify, and they should be passing parameters like you’re showing, yet they don’t.

I guess I don’t have much to add other than I concur that it’s a bug that needs to be addressed. You’re not making a feature request.

Something odd is going on, but rather than using substitute one of the \define parameter replacement methods is the backtick form.

<$let john=`fellow $(bear)$ years old`>

However I redesigned this according to some personal standards and all the problems disappeared.

\procedure track-actions()
<$action-setfield done=<<john>> work=job old=<<bear>>/>
\end
\procedure track(bear:42)
<$let john=`fellow $(bear)$ years old`>
see "<<bear>>" and <<john>>
<$button actions=<<track-actions>> >test <<bear>></$button>
</$let>
\end

# <<track>>
# <<track 64>>

@jypre Your second example seems flawed, despite re-reading it several times it just does not seem to make sense. Is there a typo in there perhaps?

For the first one, this would get you the desired outcome:
<$button actions="<<track 28>>">test 28</$button>

Note however that passing parameters as a part of widget attributes is of limited usefulness since we are limited to literal parameters rather than variables or text references.

It may be limited, but <$button actions=<<track 28>> >test 28</$button> should have still worked, shouldn’t it have?