0

I have a calculation where I give the user an advance option to choose a variable, PV. If the user chooses not to use the PV, the button calls the package without PV and the other way around. Here is what I did:

Panel[
  Column[{
    Row[{
      Checkbox[Dynamic[Apv], {False, True}], 
      Style["PV", 12, Black, Editable -> False], 
      InputField[Dynamic[PV], Number, Enabled -> Dynamic[Apv], FieldSize -> 5]
    }, Spacer[5]],
    Grid[{{
      Button[
        Style["Calculate", 14, Green, Editable -> False], 
        { calmessage = Style["Calculation started", 14, Red],
          Print[Dynamic[Apv]]; 
          If[
            Dynamic[Apv] === True, 
            Print[a]; Res2 = INT1DTF`MainD1I[u, PV], 
            Print[b]; Res2 = INT1DTF`MainD1I[u]
          ];
        };
        calmessage = Style["Calculation finished", 13, Blue]; , 
        Method -> "Queued", 
        ImageSize -> {350, 40}
      ]
     }, {
       Row[{
         InputField[Dynamic[calmessage], FieldSize -> {30, 1.5}]}, 
         Spacer[15]]}}, 
    Frame -> True]}]]

Apv allows me to understand if the user wants to use PV or not. And I have an If statement for the button to act accordingly. I use Print[Dynamic[Apv]] , Print[a] and Print[b] to see where the if statement goes. And it always goes to b. Any ideas what is missing in here?

When I toggle from checked to unchecked Print[Dynamic[Apv]] this changes. So I know I am reading Apv right.

Kuba
  • 136,707
  • 13
  • 279
  • 740
Erdem
  • 869
  • 4
  • 11
  • 1
    Dynamic[Apv] === True is always False because Dynamic will not disappear. When you display Dynamic, e.g. with your Prints, then it is still there showing current value of e.g. Apv. Just drop it from calculations: If[ Apv === True, .... – Kuba Oct 28 '18 at 16:54
  • It is true, I didn't see that questions. It is working without dynamic. – Erdem Oct 28 '18 at 17:58

0 Answers0