I am doing a time-intensive calculation and I would like to have the option to stop the calculation but obtain the current (last) result. Generally, I do some groundwork as what can be done before asking a question but this time I don't even know where to start. I wrote the "toy" version of my problem.
Here is the user interface that I would like to insert the "ABORT" button. and the "time-dependent" package.
BeginPackage["AbortCal`"];
MainAbortCal::usage=" ";
Begin["`Private`"];
MainAbortCal[tfinal_]:=Module[{a}
, a=ConstantArray[1, {50, 50}]
; Do[a=a+1; Pause[2];,{i,tfinal}]
; plta=ListPlot3D[a,ImageSize->Full]
; {plta, a}
]
End[];
EndPackage[];
Panel[
Framed[
DynamicModule[
{tfinal = 100}
, Column[{
Style["Compute","Subsection"],
Row[{Style["Final Time ",12,Blue], InputField[Dynamic[tfinal]]},Spacer[5]],
Button[Style["Compute",Green,Bold]
, Res=AbortCal`MainAbortCal[tfinal]
; Plt=Res[[1]]
; a=Res[[2]]
, Method->"Queued"
],
Row[{Button["Stop",Interrupt[];Print[Dynamic[a]]]}],
Row[{Style["Plot ",12,Red],InputField[Dynamic[Plt],FieldSize->{50,15},Enabled->False,BaseStyle->{12}]},Spacer[15]]
}]
]
, Background->Lighter[Gray,.6]
]
]
I have the Pause[2]
command there just to give me a time. I am not sure if there is a way to do what I want to do. Thank you for the help.