I am working on creating a CDF file for a calculation where I do high-precision evaluation of functions such as N[func,40]. I wrote a Module that takes user function and rationalize it, this way I create a function with user input accuracy. (Shown Below). When I don't use an inputfield my module works well but with inputfield I can't prevent it to be evaluated.
As you can see I need to avoid the evaluation so that I can evaluate the function in desired accuracy (number of digits). Any idea how I can do this?
Thank you
Erdem
Panel[DynamicModule[{fun = 2.1 Sin[Pi z/2.1]}, Column[{
Row[{Style["Function ", 12, Blue, Editable -> False],
InputField[HoldForm[Dynamic[fun]], FieldSize -> {55, 3},
BaseStyle -> {12}]}, Spacer[1]]
, Button[Style["Calculate", 14, Green, Editable -> False],
Res = upAC[fun]],
Row[{Style["Result ", 12, Red, Editable -> False],
InputField[Dynamic[Res], FieldSize -> {52, 2},
BaseStyle -> {12}]}, Spacer[5]]
}],
Initialization :> (upAC[in_] :=
Module[{out},
out = If[Accuracy[in] == \[Infinity], in,
ReleaseHold[Rationalize[in, 10^-Accuracy[in]]]];
Return[out]];)
]]
InputField
takes a form as its second argument. One possible form isHold[Expression]
which simply holds the expression you input. Will this work for you? $\endgroup$InputField[Dynamic[Hold[fun]]
I can't access to the input field. $\endgroup$HoldForm
tofun
definition insideDynamicModule
and removeHoldForm
fromInputField
, do you get what you want? $\endgroup$