3 replaced http://mathematica.stackexchange.com/ with https://mathematica.stackexchange.com/
source | link

As Sjoerd has mentioned, InputField in CDF-Player are restricted: they work, but only for input of numbers. This seems to be true for no matter whether run in the "standalone" CDF-Player or within the browser-plugin. The problem are only those InputFields that you use to show results, not the ones you use for input.

But there is another problem: you have to define all functions you are using within the Initialization. For this case, you can just use the SaveDefinitions Option, if you'd really make use of the "Units`" package you'd have to write an explicit Initialization, and making use of symbols from a package has some additional issues, which you can learn to avoid e.g. herehere.

The following should work:

DrawOdds[outs_] := 46/outs - 1;
MinImpliedOdds[bet_, pot_, remStack_, outs_] := 
  Module[{immediateOdds, odds, impliedAmt, percPot, percStack}, 
   immediateOdds = (pot + bet)/bet; odds = DrawOdds[outs];
   impliedAmt = If[immediateOdds < odds, bet (odds - 1) - pot, 0];
   percPot = impliedAmt/(pot + 2 bet);
   percStack = impliedAmt/remStack; {impliedAmt, percPot, percStack}];

Needs["Units`"];

DynamicModule[{bet = 230, pot = 380, remStack = 870, outs = 9}, 
 Deploy[Style[
   Panel[Grid[
     Transpose[{{Style["bet", Red], Style["pot", Red], 
        Style["smallest remaining stack", Red], Style["outs", Red], 
        "implied amount", "% pot", 
        "% remaining stack"}, {InputField[Dynamic[bet], Number], 
        InputField[Dynamic[pot], Number], 
        InputField[Dynamic[remStack], Number], 
        InputField[Dynamic[outs], Number], 
        Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[1]] // N], 
        Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[2]] 100 // 
          N], 
        InputField[
         Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[3]] 100 // 
           N], Number, Enabled -> False]}}], Alignment -> Right], 
    ImageMargins -> 10], 
   DefaultOptions -> {InputField -> {ContinuousAction -> True, 
       FieldSize -> {{5, 30}, {1, Infinity}}}}]], 
 SaveDefinitions -> True]

Here I just left out the InputField where it doesn't work in CDF-Player. You could try to use additional functions e.g. Framed or Panel to get a "nicer" formatting of the output numbers so that they look like disabled input fields...

As Sjoerd has mentioned, InputField in CDF-Player are restricted: they work, but only for input of numbers. This seems to be true for no matter whether run in the "standalone" CDF-Player or within the browser-plugin. The problem are only those InputFields that you use to show results, not the ones you use for input.

But there is another problem: you have to define all functions you are using within the Initialization. For this case, you can just use the SaveDefinitions Option, if you'd really make use of the "Units`" package you'd have to write an explicit Initialization, and making use of symbols from a package has some additional issues, which you can learn to avoid e.g. here.

The following should work:

DrawOdds[outs_] := 46/outs - 1;
MinImpliedOdds[bet_, pot_, remStack_, outs_] := 
  Module[{immediateOdds, odds, impliedAmt, percPot, percStack}, 
   immediateOdds = (pot + bet)/bet; odds = DrawOdds[outs];
   impliedAmt = If[immediateOdds < odds, bet (odds - 1) - pot, 0];
   percPot = impliedAmt/(pot + 2 bet);
   percStack = impliedAmt/remStack; {impliedAmt, percPot, percStack}];

Needs["Units`"];

DynamicModule[{bet = 230, pot = 380, remStack = 870, outs = 9}, 
 Deploy[Style[
   Panel[Grid[
     Transpose[{{Style["bet", Red], Style["pot", Red], 
        Style["smallest remaining stack", Red], Style["outs", Red], 
        "implied amount", "% pot", 
        "% remaining stack"}, {InputField[Dynamic[bet], Number], 
        InputField[Dynamic[pot], Number], 
        InputField[Dynamic[remStack], Number], 
        InputField[Dynamic[outs], Number], 
        Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[1]] // N], 
        Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[2]] 100 // 
          N], 
        InputField[
         Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[3]] 100 // 
           N], Number, Enabled -> False]}}], Alignment -> Right], 
    ImageMargins -> 10], 
   DefaultOptions -> {InputField -> {ContinuousAction -> True, 
       FieldSize -> {{5, 30}, {1, Infinity}}}}]], 
 SaveDefinitions -> True]

Here I just left out the InputField where it doesn't work in CDF-Player. You could try to use additional functions e.g. Framed or Panel to get a "nicer" formatting of the output numbers so that they look like disabled input fields...

As Sjoerd has mentioned, InputField in CDF-Player are restricted: they work, but only for input of numbers. This seems to be true for no matter whether run in the "standalone" CDF-Player or within the browser-plugin. The problem are only those InputFields that you use to show results, not the ones you use for input.

But there is another problem: you have to define all functions you are using within the Initialization. For this case, you can just use the SaveDefinitions Option, if you'd really make use of the "Units`" package you'd have to write an explicit Initialization, and making use of symbols from a package has some additional issues, which you can learn to avoid e.g. here.

The following should work:

DrawOdds[outs_] := 46/outs - 1;
MinImpliedOdds[bet_, pot_, remStack_, outs_] := 
  Module[{immediateOdds, odds, impliedAmt, percPot, percStack}, 
   immediateOdds = (pot + bet)/bet; odds = DrawOdds[outs];
   impliedAmt = If[immediateOdds < odds, bet (odds - 1) - pot, 0];
   percPot = impliedAmt/(pot + 2 bet);
   percStack = impliedAmt/remStack; {impliedAmt, percPot, percStack}];

Needs["Units`"];

DynamicModule[{bet = 230, pot = 380, remStack = 870, outs = 9}, 
 Deploy[Style[
   Panel[Grid[
     Transpose[{{Style["bet", Red], Style["pot", Red], 
        Style["smallest remaining stack", Red], Style["outs", Red], 
        "implied amount", "% pot", 
        "% remaining stack"}, {InputField[Dynamic[bet], Number], 
        InputField[Dynamic[pot], Number], 
        InputField[Dynamic[remStack], Number], 
        InputField[Dynamic[outs], Number], 
        Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[1]] // N], 
        Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[2]] 100 // 
          N], 
        InputField[
         Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[3]] 100 // 
           N], Number, Enabled -> False]}}], Alignment -> Right], 
    ImageMargins -> 10], 
   DefaultOptions -> {InputField -> {ContinuousAction -> True, 
       FieldSize -> {{5, 30}, {1, Infinity}}}}]], 
 SaveDefinitions -> True]

Here I just left out the InputField where it doesn't work in CDF-Player. You could try to use additional functions e.g. Framed or Panel to get a "nicer" formatting of the output numbers so that they look like disabled input fields...

2 added note about cdf-plugin
source | link

As Sjoerd has mentioned, InputField in CDF-Player are restricted: they work, but only for input of numbers. This seems to be true for no matter whether run in the "standalone" CDF-Player or within the browser-plugin. The problem are only those InputFields that you use to show results, not the ones you use for input.

But there is another problem: you have to define all functions you are using within the Initialization. For this case, you can just use the SaveDefinitions Option, if you'd really make use of the "Units`" package you'd have to write an explicit Initialization, and making use of symbols from a package has some additional issues, which you can learn to avoid e.g. here.

The following should work:

DrawOdds[outs_] := 46/outs - 1;
MinImpliedOdds[bet_, pot_, remStack_, outs_] := 
  Module[{immediateOdds, odds, impliedAmt, percPot, percStack}, 
   immediateOdds = (pot + bet)/bet; odds = DrawOdds[outs];
   impliedAmt = If[immediateOdds < odds, bet (odds - 1) - pot, 0];
   percPot = impliedAmt/(pot + 2 bet);
   percStack = impliedAmt/remStack; {impliedAmt, percPot, percStack}];

Needs["Units`"];

DynamicModule[{bet = 230, pot = 380, remStack = 870, outs = 9}, 
 Deploy[Style[
   Panel[Grid[
     Transpose[{{Style["bet", Red], Style["pot", Red], 
        Style["smallest remaining stack", Red], Style["outs", Red], 
        "implied amount", "% pot", 
        "% remaining stack"}, {InputField[Dynamic[bet], Number], 
        InputField[Dynamic[pot], Number], 
        InputField[Dynamic[remStack], Number], 
        InputField[Dynamic[outs], Number], 
        Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[1]] // N], 
        Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[2]] 100 // 
          N], 
        InputField[
         Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[3]] 100 // 
           N], Number, Enabled -> False]}}], Alignment -> Right], 
    ImageMargins -> 10], 
   DefaultOptions -> {InputField -> {ContinuousAction -> True, 
       FieldSize -> {{5, 30}, {1, Infinity}}}}]], 
 SaveDefinitions -> True]

Here I just left out the InputField where it doesn't work in CDF-Player. You could try to use additional functions e.g. Framed or Panel to get a "nicer" formatting of the output numbers so that they look like disabled input fields...

As Sjoerd has mentioned, InputField in CDF-Player are restricted: they work, but only for input of numbers. The problem are only those InputFields that you use to show results, not the ones you use for input.

But there is another problem: you have to define all functions you are using within the Initialization. For this case, you can just use the SaveDefinitions Option, if you'd really make use of the "Units`" package you'd have to write an explicit Initialization, and making use of symbols from a package has some additional issues, which you can learn to avoid e.g. here.

The following should work:

DrawOdds[outs_] := 46/outs - 1;
MinImpliedOdds[bet_, pot_, remStack_, outs_] := 
  Module[{immediateOdds, odds, impliedAmt, percPot, percStack}, 
   immediateOdds = (pot + bet)/bet; odds = DrawOdds[outs];
   impliedAmt = If[immediateOdds < odds, bet (odds - 1) - pot, 0];
   percPot = impliedAmt/(pot + 2 bet);
   percStack = impliedAmt/remStack; {impliedAmt, percPot, percStack}];

Needs["Units`"];

DynamicModule[{bet = 230, pot = 380, remStack = 870, outs = 9}, 
 Deploy[Style[
   Panel[Grid[
     Transpose[{{Style["bet", Red], Style["pot", Red], 
        Style["smallest remaining stack", Red], Style["outs", Red], 
        "implied amount", "% pot", 
        "% remaining stack"}, {InputField[Dynamic[bet], Number], 
        InputField[Dynamic[pot], Number], 
        InputField[Dynamic[remStack], Number], 
        InputField[Dynamic[outs], Number], 
        Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[1]] // N], 
        Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[2]] 100 // 
          N], 
        InputField[
         Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[3]] 100 // 
           N], Number, Enabled -> False]}}], Alignment -> Right], 
    ImageMargins -> 10], 
   DefaultOptions -> {InputField -> {ContinuousAction -> True, 
       FieldSize -> {{5, 30}, {1, Infinity}}}}]], 
 SaveDefinitions -> True]

Here I just left out the InputField where it doesn't work in CDF-Player. You could try to use additional functions e.g. Framed or Panel to get a "nicer" formatting of the output numbers so that they look like disabled input fields...

As Sjoerd has mentioned, InputField in CDF-Player are restricted: they work, but only for input of numbers. This seems to be true for no matter whether run in the "standalone" CDF-Player or within the browser-plugin. The problem are only those InputFields that you use to show results, not the ones you use for input.

But there is another problem: you have to define all functions you are using within the Initialization. For this case, you can just use the SaveDefinitions Option, if you'd really make use of the "Units`" package you'd have to write an explicit Initialization, and making use of symbols from a package has some additional issues, which you can learn to avoid e.g. here.

The following should work:

DrawOdds[outs_] := 46/outs - 1;
MinImpliedOdds[bet_, pot_, remStack_, outs_] := 
  Module[{immediateOdds, odds, impliedAmt, percPot, percStack}, 
   immediateOdds = (pot + bet)/bet; odds = DrawOdds[outs];
   impliedAmt = If[immediateOdds < odds, bet (odds - 1) - pot, 0];
   percPot = impliedAmt/(pot + 2 bet);
   percStack = impliedAmt/remStack; {impliedAmt, percPot, percStack}];

Needs["Units`"];

DynamicModule[{bet = 230, pot = 380, remStack = 870, outs = 9}, 
 Deploy[Style[
   Panel[Grid[
     Transpose[{{Style["bet", Red], Style["pot", Red], 
        Style["smallest remaining stack", Red], Style["outs", Red], 
        "implied amount", "% pot", 
        "% remaining stack"}, {InputField[Dynamic[bet], Number], 
        InputField[Dynamic[pot], Number], 
        InputField[Dynamic[remStack], Number], 
        InputField[Dynamic[outs], Number], 
        Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[1]] // N], 
        Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[2]] 100 // 
          N], 
        InputField[
         Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[3]] 100 // 
           N], Number, Enabled -> False]}}], Alignment -> Right], 
    ImageMargins -> 10], 
   DefaultOptions -> {InputField -> {ContinuousAction -> True, 
       FieldSize -> {{5, 30}, {1, Infinity}}}}]], 
 SaveDefinitions -> True]

Here I just left out the InputField where it doesn't work in CDF-Player. You could try to use additional functions e.g. Framed or Panel to get a "nicer" formatting of the output numbers so that they look like disabled input fields...

1
source | link

As Sjoerd has mentioned, InputField in CDF-Player are restricted: they work, but only for input of numbers. The problem are only those InputFields that you use to show results, not the ones you use for input.

But there is another problem: you have to define all functions you are using within the Initialization. For this case, you can just use the SaveDefinitions Option, if you'd really make use of the "Units`" package you'd have to write an explicit Initialization, and making use of symbols from a package has some additional issues, which you can learn to avoid e.g. here.

The following should work:

DrawOdds[outs_] := 46/outs - 1;
MinImpliedOdds[bet_, pot_, remStack_, outs_] := 
  Module[{immediateOdds, odds, impliedAmt, percPot, percStack}, 
   immediateOdds = (pot + bet)/bet; odds = DrawOdds[outs];
   impliedAmt = If[immediateOdds < odds, bet (odds - 1) - pot, 0];
   percPot = impliedAmt/(pot + 2 bet);
   percStack = impliedAmt/remStack; {impliedAmt, percPot, percStack}];

Needs["Units`"];

DynamicModule[{bet = 230, pot = 380, remStack = 870, outs = 9}, 
 Deploy[Style[
   Panel[Grid[
     Transpose[{{Style["bet", Red], Style["pot", Red], 
        Style["smallest remaining stack", Red], Style["outs", Red], 
        "implied amount", "% pot", 
        "% remaining stack"}, {InputField[Dynamic[bet], Number], 
        InputField[Dynamic[pot], Number], 
        InputField[Dynamic[remStack], Number], 
        InputField[Dynamic[outs], Number], 
        Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[1]] // N], 
        Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[2]] 100 // 
          N], 
        InputField[
         Dynamic[MinImpliedOdds[bet, pot, remStack, outs][[3]] 100 // 
           N], Number, Enabled -> False]}}], Alignment -> Right], 
    ImageMargins -> 10], 
   DefaultOptions -> {InputField -> {ContinuousAction -> True, 
       FieldSize -> {{5, 30}, {1, Infinity}}}}]], 
 SaveDefinitions -> True]

Here I just left out the InputField where it doesn't work in CDF-Player. You could try to use additional functions e.g. Framed or Panel to get a "nicer" formatting of the output numbers so that they look like disabled input fields...