Message Boards Message Boards

Avoid "Null" statement inside the user interface with Manipulate?

Posted 9 years ago

Hello, I am developing an application and in that application I am giving an option to user to ploy some functions or not. I do that through a checkbox. It is working fine but when the value of the checkbox is False there is "Null" statement where the figure might have been. Is there a way to avoid that? Thank you.

Manipulate[
 DynamicModule[{f = Sin[x], xR = 1, xL = 0, 
   Res = 0.4596976941318603`16, fp = False}, 
  Column[{Style["1D Definite Integral Calculator", "Function"], 
    Row[{"Lower Limit ", InputField[Dynamic[xL], Number]}, Spacer[5]],
     Row[{"Upper Limit ", InputField[Dynamic[xR], Number]}, 
     Spacer[5]], 
    Row[{"Function  ", InputField[Dynamic[f]]}, Spacer[20]], 
    Button[Style["Calculate", Green, Bold], 
     Dynamic[Res = DGL[f, xR, xL, np, nw];]], 
    Row[{"Result", InputField[Dynamic[Res], Enabled -> False]}, 
     Spacer[51]], 
    Row[{"Plot the Function ", Checkbox[Dynamic[fp], {False, True}]}],
     Dynamic[
     If[fp == True, 
      InputField[
       Dynamic[Plot[f, {x, xL, xR}, Dynamic[PlotLabel -> f], 
         ImageSize -> Full]], FieldSize -> {30, 15}]]]
    }]], {{np, 16, "NumberFormat"}, 
  ControlPlacement -> Bottom}, {{nw, 16, "WorkingPrecision"}, 
  ControlPlacement -> Bottom}, 
 Initialization :> (DGL[f_, xR_, xL_, np_, nw_] := Module[{},
     ResultTF = 
      SetPrecision[
       NIntegrate[f, {x, xL, xR}, 
        WorkingPrecision -> Re[IntegerPart[nw]]], 
       Re[IntegerPart[np]]]])]
POSTED BY: Erdem Uguz
2 Replies
Posted 9 years ago

Thanks

POSTED BY: Erdem Uguz
Posted 9 years ago

Add an empty string as third argument to the If function:

If[fp == True,
  InputField[
    Dynamic[
      Plot[f, {x, xL, xR}, Dynamic[PlotLabel -> f], ImageSize -> Full]
    ],
    FieldSize -> {30, 15}
  ],
  ""
]
POSTED BY: Hans Milton
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