How to set the values of a multi-valued parameter of a procedure into separate tiddler fields sequentially

I am trying to set the values ( one, two, three in this example) of a multi-valued parameter called tbl_fields of a procedure called dy-tbl into separate tiddler fields like tbl-field-1, tbl-field-2, tbl-field-3 and so on using a button.

That is one in tbl-field-1 , two in tbl-field-2 , three in tbl-field-3 and so on.

Below given is the code I tried. But only one of the value of this multi-valued parameter is getting added to all the fields using this button.

I am getting three as value in all fields tbl-field-1, tbl-field-2, tbl-field-3

I want to add each of the sequential values of that parameter into separate fields sequentially in the same order as the parameter values.

Can some one help . This is part of my my solution to avoid double storage as mentioned in this post - Replace certain values in list field using edit text and action widgets - #10 by pmario

Here is the demo wiki for testing my code

\procedure append-parameters-to-fields()
<$list filter="[<tbl_fields>enlist-input[]]" variable="tbl_field_value">
<$let 
tbl_column_count_number={{{ [<tbl_fields>enlist-input[]count[]] }}}
>
<$list filter="[range[1],<tbl_column_count_number>]" variable="tbl_column_count" >
<$let
tbl-fields-name={{{ [[tbl-field-]addsuffix<tbl_column_count>] }}}
>
<$action-setfield $tiddler=<<currentTiddler>> $field=<<tbl-fields-name>> $value=<<tbl_field_value>> $timestamp="no"/>
</$let>
</$list>
</$let>
</$list>
\end

\procedure dy-tbl(tbl_fields)

<$button tooltip="append-parameters-to-fields" actions=<<append-parameters-to-fields>> >
Append parameters to fields
</$button>

\end

<<dy-tbl tbl_fields:"one two three">>

Try this:

\procedure append-parameters-to-fields()
<$list filter="[<tbl_fields>enlist-input[]]" variable="tbl_field_value" counter="tbl_column_num">
   <$let tbl-fields-name={{{ [[tbl-field-]addsuffix<tbl_column_num>] }}}>
      <$action-setfield $field=<<tbl-fields-name>> $value=<<tbl_field_value>> $timestamp="no"/>
   </$let>
</$list>
\end

Notes:

  • The $list widget uses the counter=... parameter to get the corresponding list item’s number.
  • The $action-setfield omits the $tiddler=<<currentTiddler>> parameter, since the current tiddler is used as the default when no $tiddler is specified.

enjoy,
-e

1 Like

Thank you soo much @EricShulman . I guess this will solve all my problems regarding my custom dynamic table. Once again thanks