I don’t believe you can invoke/use an action code var inside a ^value()^. Also if you use a var in an ^action()^ sections of a template the var only works inside that code and not throughout the template. So, if you need to use a variable value in a ^value()^ you will have to use an attribute to cache the value. Here is a simple value (the section ^action()^ section is simply to rest the the cache attribute):
The whitespace line-beaks in the action sections are for clarity only.
In terms of HTML output, line-breaks inside ^action()^ are ignored but line breaks before/after the code are emitted. Thus the above would emit 3 discrete lines to HTML, first/last will emtpy lines and the middle one will have the ^value()^ output. To use one line of output leave no breats between the export codes, like so:
^action(
var tmp($MyNumber);
$MyList = collect_if(all,$MyNumber=tmp,$Name);
)^^value($MyList.format(", "))^^action(
$MyList=;
)^
We don’t have to worry about line breaks inside the ^action()^ codes.