I am trying to create a dialog box that informs the user when the input is wrong (or even when any type of error occurs) in the manipulate function.
I have the following code:
Plotter[function_] :=
Plot[function, {x, -1, 1}, PlotLabel -> Style [function, Bold]];
Manipulate[
Quiet[Plotter[f]], {{f, Sin[x],
Text[Style["Function:", Bold, Medium]]}, {Sin[x], Tan[x]}
}, Text[Style["\nType the function:", Bold]],
Panel[DynamicModule[{var = "Function"}, InputField[Dynamic[f]]]],
ControlPlacement -> Left, ControlType -> PopupMenu,
SaveDefinitions -> True, SynchronousInitialization -> False]
And I implemented the dialog box in the following way:
Plotter[function_] :=
Plot[function, {x, -1, 1}, PlotLabel -> Style [function, Bold]];
Manipulate[
Quiet[Check[Plotter[f], {MessageDialog["Error."], Abort[]}]], {{f,
Sin[x], Text[Style["Function:", Bold, Medium]]}, {Sin[x], Tan[x]}
}, Text[Style["\nType the function:", Bold]],
Panel[DynamicModule[{var = "Function"}, InputField[Dynamic[f]]]],
ControlPlacement -> Left, ControlType -> PopupMenu,
SaveDefinitions -> True, SynchronousInitialization -> False]
which seems to work up until the point when I try to type another function. The plotting does not work and the error box does not appear anymore when the input is wrong. Why does this happen? And how to I fix this? I think that the Abort[]
function causes this, but if I do not put it there, the message box appears indefinitely.
I created the error with the user input "Sin[x,y]"
.