Call a procedure from a procedure and give over parameter

Hi TW-Community,

I don’t find out how to call a procedure from a procedure and to give over the parameter.

Situation is:
Three global procedures show_table and edit_table and show_edit_table.

In the procedure show_edit_table I try to call show_table and edit_table with the same parameter but it failed. I thought to use << >> but this is definitely wrong.

code-body: yes
tags: $:/tags/Global
title: proc/show_edit_table

\whitespace trim
\procedure show_edit_table(fields)

<<show_table <<fields>> >>
<<edit_table <<fields>> >>
\end
code-body: yes
tags: $:/tags/Global
title: proc/edit_table

\whitespace trim
\procedure edit_table(fields)
<$let
	currTidd=<<currentTiddler>>
>

Here we are:<br>
<table>
	<$list filter="[enlist<fields>]" variable="field">
	 <tr>
		<th><$edit-text tiddler=<<currTidd>> field=<<field>>/>
        </th>
	 </tr>
 	</$list>
</table>
</$let>
\end
code-body: yes
tags: $:/tags/Global
title: proc/show_table

\whitespace trim
\procedure show_table(fields)
<$let
	currTidd=<<currentTiddler>>
>

Here we are:<br>
<table>
	<$list filter="[enlist<fields>]" variable="field">
	 <tr>
		<th><$view tiddler=<<currTidd>> field=<<field>>/>
        </th>
	 </tr>
 	</$list>
</table>
</$let>
\end
AAA: Content of AAA
BBB: Content of BBB
CCC: Content of CCC
tags: 
title: Debug_Tiddler

! Show table
<<show_table "AAA BBB CCC">>

! Edit table
<<edit_table "AAA BBB CCC">>

! Show and Edit table
<<show_edit_table "AAA BBB CCC">>

And this is the output.
show_table :ok:
edt_table :ok:
show_edt_table :x:

Stefan

To use variables (e.g., <<fields>>) as parameters to a procedure or macro, you can use the $macrocall widget, like this:

<$macrocall $name=show_table fields=<<fields>>/>
<$macrocall $name=edit_table fields=<<fields>>/>

-e

3 Likes

Hi @EricShulman ,

What syntax I have to use if I have more than one parameter?

<$macrocall $name=show_table fields=[<<fields>> <<other_parameter>> <<other_fields>>] />

is not working as expected.

Thx in advance
Stefan

Have a look at the syntax in the documentation:

https://tiddlywiki.com/#MacroCallWidget

$macrocall allows multiple named parameters to be passed.

For your use-case, something like this:

<$macrocall $name=show_table fields=<<fields>>
   other_parameter=<<other_parameter>> other_fields=<<other_fields>> />

-e

1 Like

Thank you @EricShulman ,
I was not aware of this possibility in macrocall.
Finally I found a cross reference documentation for transclude and if I understood it right this is the up to date solution.

Nevertheless, your and also the transclusion solution is working as expected.

<$macrocall $name=show_table fields=<<fields>>
   other_parameter=<<other_parameter>> other_fields=<<other_fields>> />

is doing the same

<$transclude $variable="show_table " fields=<<fields>>
   other_parameter=<<other_parameter>> other_fields=<<other_fields>> />

Stefan