1
$\begingroup$

I am finishing my first program in Wolfram Mathematica 10 and if I have almost completed is essentially thanks to this valuable forum soon where I will try to help too.

Basically, now I have this problem: to make work a routine I used Button["Start", Module[{}, 'routine']]. Unfortunately, in this program you need to change the routine manually and then later by clicking on "Start" I can not consider the changes by not clicking "Shift + Enter". How can I do?


You're right MarcoB.

In reference to the following portion of my program:

enter image description here

when I edit the data and then click on "Risolvi" variable "sol" is not updated, but it remains in the old values. How can I fix without having to click "Shift + Enter"?


Equivalently, because the following code does not work if you click on the button ??

Button["Update", Module[{},
Function[cobj, SelectionMove[cobj, Cell, All];
    SelectionEvaluate[InputNotebook[]];]~Scan~
   TakeWhile[Cells[CellStyle -> "Input"], # =!= EvaluationCell[] &];
  SelectionMove[EvaluationCell[], After, Cell];]]
$\endgroup$
  • $\begingroup$ Manu, unfortunately I can't quite follow your explanation. Could you please provide examples? A minimal code example showcasing your problem would be best. You can always edit your question by using the "edit" link under the question. $\endgroup$ – MarcoB Aug 19 '15 at 21:51
  • $\begingroup$ I believe you should explain the following sentence further: "Unfortunately, in this program you need to change the routine manually and then later by clicking on "Start" I can not consider the changes by not clicking "Shift + Enter"" $\endgroup$ – Dr. belisarius Aug 20 '15 at 1:24
2
$\begingroup$

I'm guessing that you want to produce an interactive application in which the user changes any of a set of parameters and then clicks on a button to indicate that the new parameters are to applied. That sort of thing is usually done within a Manipulate expression. Here is an simple example of such an expression -- a solver for quadratic equations.

Manipulate[
  If[solve, solve = False; solution = update[]];
  Style[
    Column[{
      Row[{"Equation: ", TraditionalForm[a x^2 + b x + c == 0]}],
      Row[{"Solution: ", solution}]}],
    "Text"],
  Style["Coefficients", Bold, 11],
  {{a, 1}},
  {{b, 0}},
  {{c, -1}},
  {{solve, False}, None},
  {{solution, {{x -> -1}, {x -> 1}}}, None},
  Button["Solve", solve = True, ImageSize -> Automatic],
  Initialization :> (update[] := Solve[ a x^2 + b x + c == 0, x]),
  TrackedSymbols :> {solve, solution},
  ControlPlacement -> Bottom]

quad

Making changes to any of the three input fields has no effect until the Solve button is clicked. Since you are working on your first Mathematica program, there is probably a lot in the above example that will be new and strange to you, but I hope you will study it and that it will help you to develop the application you are working on.

References

$\quad \quad $Introduction to Manipulate

$\quad \quad $Advanced Manipulate Functionality

| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.