On Wed, 17 Aug 2011, Riccardo (Jack) Lucchetti wrote:
On Tue, 9 Aug 2011, amaryl wrote:
> On Mon, 2011-08-08 at 22:04 -0400, Allin Cottrell wrote:
>> On Tue, 2 Aug 2011, Summers, Peter wrote:
>>
>>>> Sometimes a tool to forcibly terminate a running script would come very
>>> handy, too. Maybe a combined "Start/Stop" button or something
alike.
>>>
>>> I found myself looking for the "stop" button just yesterday ;-).
>>
>>> From a programmer's point of view, the question is: where should we
>> stick the handlers for aborting a script? Is everyone who's putting
>> forward this idea thinking in terms of breaking out of a gretl loop?
>>
>> Notice that you have a "break" command for loops, so with some
>> foresight you can arrange a conditional breakout if things are not
>> going well.
>
> Personally, I am not thinking of breaking out of faulty loops.
> In one of my scripts I had a lot of time-consuming loops. When I wanted
> to check changes in my script not directly related to the loops, I
> usually commented them out, but occasionally I forgot. A stop-button
> would have been useful. "break" obviously doesn't help me in that
case.
>
> In general, I think a stop-button is useful in cases where you notice
> that you have lacked foresight ;-)
The problem with a "break" button is that the program has to constantly check
if the button has been pressed and, if so, take the appropriate action. This
slows down execution and I personally don't like it very much. This said, it
has happened to me to long for a break button, like for example when you run
some estimation command that is known to take minutes and you realise just
after having pressed "OK" that you forgot to add a variable or so.
What we may want to do is think about some mechanism for interrupting the
current command in the GUI client, and advise users to use the unstoppable
might of the CLI client if performance is of paramount importance. Thoughts?
Stopping gretlcli is no problem: good old Ctrl-C. I agree that one
might sometimes want a way of stopping execution in the GUI (though
there's xkill and equivalents).
In CVS I've added a Stop button to the toolbar in the script editor
window. This is checked by a callback at the top of the main
command-line execution function in libgretl. So script execution
should halt, if this button is clicked, as soon as the next line
comes up for execution.
It's not so easy to stop execution of a time-consuming built-in
command. That would require peppering the functions within libgretl
with calls to check the stop button status. However, we could also
add a stop button to the dialog boxes used to fire up "addons" and
other function packages, since these are script-based and would be
caught by the command-line blocker.
Allin Cottrell