# How to code Control changes?

**URL:** <https://community.wolfram.com/t/how-to-code-control-changes/26143>\
**Category:** Questions\
**Tags:** interface-construction\
**Created:** [November 14, 2025, 5:33pm UTC](https://community.wolfram.com/t/how-to-code-control-changes/26143 "2025-11-14T17:33:56Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wernergg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/wernergg/32/6481_2.png) [@wernergg](https://community.wolfram.com/u/wernergg)\
**Post date:** [November 14, 2025, 5:33pm UTC](https://community.wolfram.com/t/how-to-code-control-changes/26143/1 "2025-11-14T17:33:56Z")

</div>

I have a small DynamicModule that displays a slider for x and the result of evaluating a function f[x].  
The following code works as desired:

```
DynamicModule[{f, x = 5},
 f[x_] := {x, Sqrt[x]};
 Column[{
   Slider[Dynamic@x, {0, 25, 1}],
   Dynamic@f[x]
   }]
 ]

```

 ![Screenshot2025-11-14182646.jpg](https://global.discourse-cdn.com/wolfram/original/3X/d/c/dce5b59d0b954bcb9e42ae9a8a870a9bfdd695d9.jpeg)

Now I want to store the results of f[x] in two variables arg and val for later use.  
The following code works, but it throws a Set::shape error during the assignment of the result, and the variables arg and val are not set.

```
DynamicModule[{f, x = 5, arg, val},
 f[x_] := {x, Sqrt[x]};
 Column[{
   Slider[Dynamic@x, {0, 25, 1}],
   {arg, val} = Dynamic@f[x],
   Row[{"{arg,val} = ", Dynamic@{arg, val}}]
   }]
 ]

```

 ![Screenshot2025-11-14183123.jpg](https://global.discourse-cdn.com/wolfram/original/3X/6/6/66f1e9b1a811ef6c645543f537bc75b4f090657e.jpeg)

_The reason for the error is that Dynamic@f[x] is an object and not a list._

**How can I fix this problem?**  
Perhaps with something like Dynamic[f[x], someFunction] instead of {arg,val}=Dynamic[f[x]], where someFunction assigns arg and val?

---

<div class="post-metadata">

**Author:** ![gianlucagorni](https://avatars.discourse-cdn.com/v4/letter/g/ec9cab/32.png) [@gianlucagorni](https://community.wolfram.com/u/gianlucagorni)\
**Post date:** [November 14, 2025, 7:02pm UTC](https://community.wolfram.com/t/how-to-code-control-changes/26143/2 "2025-11-14T19:02:38Z")

</div>

This variant seems to work:

```
DynamicModule[{f, x = 5, arg, val},
 f[x_] := {x, Sqrt[x]};
 Column[{Slider[Dynamic@x, {0, 25, 1}],
   Dynamic[{arg, val} = f[x]],
   Row[{"{arg,val} = ", Dynamic@{arg, val}}]}]]

```

---

<div class="post-metadata">

**Author:** ![dreiss1](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dreiss1/32/6907_2.png) [@dreiss1](https://community.wolfram.com/u/dreiss1)\
**Post date:** [November 14, 2025, 8:40pm UTC](https://community.wolfram.com/t/how-to-code-control-changes/26143/3 "2025-11-14T20:40:33Z")

</div>

Or using a multi argument Dynamic like this

```
DynamicModule[{f, x, arg, val},
 f[x_] := {x, Sqrt[x]};
 x = 0;
 {arg, val} = f[x];
 
 Column[
  {Slider[
    Dynamic[x,
     (
       x = #;
       {arg, val} = f[x]
       ) &
     ],
    {0, 25, 1}
    ],
   Row[{"{arg,val} = ", Dynamic@{arg, val}}]}]
 ]

```

---

<div class="post-metadata">

**Author:** ![wernergg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/wernergg/32/6481_2.png) [@wernergg](https://community.wolfram.com/u/wernergg)\
**Post date:** [November 16, 2025, 11:41am UTC](https://community.wolfram.com/t/how-to-code-control-changes/26143/4 "2025-11-16T11:41:58Z")

</div>

This works. Thanks David.

---

<div class="post-metadata">

**Author:** ![wernergg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/wernergg/32/6481_2.png) [@wernergg](https://community.wolfram.com/u/wernergg)\
**Post date:** [November 16, 2025, 11:48am UTC](https://community.wolfram.com/t/how-to-code-control-changes/26143/5 "2025-11-16T11:48:44Z")

</div>

This works. Thanks Gianluca.

(I think I tried this before. No idea why I thought it would not work).
