Message Boards Message Boards

Dynamic controls not working properly

Posted 2 years ago

Often when using Dynamic controls in a Nb, I run into the following :

Often a line of code with a Dynamic variable in it, only works if the result (which is an intermediate result, which I do not want to see)is being outputted to the Notebook. As soon as I suppress the output with a ; (semicolon) , the script stops working.

I do not have a clue, although a read I think all of the documentaion on Dynamic.

I have attached a Notebook with an example of what I mean.
I have set the code in RED where the problem is happening.
The version of those two lines that work, are just below and only need to be uncommented.

I hope my example is clear :-)

Thanks, Beat

Attachments:
POSTED BY: B. Cornas
Posted 2 years ago

I'm honestly not sure why one works and the other doesn't. I'm actually surprised that either of them works, but I sometimes have difficulty wrapping my head around what Dynamic is doing when wrapped around more complicated expressions.

But I have two suggestions:

  • Just ditch the inputLengths2 and inputAngles2. In your Graphics expression, replace Transpose[{inputLengths2 , inputAngles2}] with Take[Transpose[{inputLengths , inputAngles}], numLines]
  • Don't try to generate your own dynamic display widget. Use Manipulate instead.
POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract