I have a custom function which demands much time (maybe several hours) to calculate result. I wanted to call the function from dynamic interface, where I define input variables and call the function by button. I found that the function outputs results differently from the case, when I call it without interface. And calculation is aborted after short time without any error message. The function is outside the interface. I tried different methods to force the function to run till end of calculation but in vain. I made a simple example to show the problem.
(*Example of function with long time of execution*)
long[max_] := Block[{ max1},
max1 = max;
Print["max=", max1];
Table[Print[i, " ", ProgressIndicator[i, {0, max}]]; Pause[2],
{i, 1, max1}];
Print["End"]
]
(*Call of long[max]*)
long[8]
The function runs till end.
(*Call of the same function from interface*)
DynamicModule[{},
Column[{
Row[{Control[{n, {3, 5, 8, 10, 20}}]}],
Button["Start", long[n]]}]
]
The function terminates after 6 sec of running
Is it possibility to call slow function from dynamic interface?
Attachments: