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.