# can i create a variable which is a list and the values given as placeholders?

I have a bit of a weird question: I have a program which I transformed from an old Mathcad Program written by someone else which is a hot mess. It uses a bunch of constants in lists as inputs in various places. This isn't really important for the question, but I want to underline that it is unavoidable in this context (without some major rewrite which I am unwilling to do at this point!).

At the moment I have a few lists of these values which I wrote manually like so:

var1={val1,val2,val3,...,valn}
var2={val1,val2,val3,...,valn}
var3={val1,val2,val3,...,valn}


All values are numbers and some of them need changing and as it is now it is difficult to change because for example I need to change val3 in var2 and I need to be careful all the time. My question is: is there a way to create some sort of graphical table with placeholders and a comment next to each placeholder for extra info, where I input the values val1,val2,val3 etc, such that they all belong to list var1? Then I modify for example val1 and the list is updated accordingly. Also, in the program I should be able to use the list as usual.

I know about DynamicModule but I have no clue if I can use these with a graphical placeholder of sorts to create lists of constants that can then be used later in the program.

When may misuse Input for your purpose.

Assume that your initial values are given in var and the corresponding info in info (note both vectors must have the same length), the following function returns the corrected values:

getVar[var_, info_] := Module[{out},
Input[
Manipulate[
, {{tab, Transpose[{var, info}], "Variables"},
Grid[Table[
With[{i = i, j = j},
InputField[
Dynamic[tab[[i, j]], (tab[[i, j]] = #;
out = tab[[All, 1]];) &], ImageSize -> Tiny]], {i,
3}, {j, 2}]] &}]
, "Click O.K. when done"]; out]


Here is a small teste example:

var = {1, 2, 3};
info = {"aaa", "bbb", "ccc"}
getVar[var, info]


We may no change the values:

After clicking "O.K." we get the result:

{111, 222, 333}

• thank you for this answer! when you say "we get the answer" does that mean that var is updated to the new values? Apr 18, 2021 at 12:59
• The return value of the function is the updated value. To update var you would write: var= getVar[var,info] Apr 18, 2021 at 13:06
• aha! this is great! I think I can create a workflow with this solution! thank you for this! Apr 18, 2021 at 13:11