When interrupting a bad fit via CTRL-C, you're offered the choice to Stop fit/Continue/Execute script, but you cannot stop the whole script, e.g. by pressing CRTL-C another time.
So if you are in a loop, fitting a larger number of datasets, you can't get out except by killing gnuplot.
I thought about putting "exit" or "break" into FIT_SCRIPT via "set fit script" but that doesn't work. Should it?
Here's an ugly four-liner for testing:
set samp 400
f(x) = (d=d/1.2,(a+d)*cos(b+x*c));a=b=c=d=1
plot "+" us 1:(1+rand(0.)),f(x)
while (1) {a=b=c=d=1;fit f(x) "+" us 1:(1+rand(0.)) via a,b,c}
(I couldn't think of a simple artificial fit that really takes forever, so you sometimes can stop this one with CTRL-C if you hit it between two fits.)
I'm on win7/gp5.2.pl2 .
I have never looked at this before, so all I can offer from the top of my head is a variant on "don't do that!". Instead make an exit condition for your loop and have the fit script set that condition. E.g.
That works but requires 2 ctrl-C operations:
(S)top fit, (C)ontinue, (E)xecute FIT_SCRIPT: e
executing: done = 1
(S)top fit, (C)ontinue, (E)xecute FIT_SCRIPT: c
gnuplot>
If you dig deeper maybe you can construct a variant that works on the 1st ctrl-C.
If what you want is to exit the whole gnuplot session rather than return to the command line, another option is:
Thanks! Good idea to set a flag in FIT_SCRIPT, that works fine.
Less elegant: I found that hitting CTRL-C several times before pressing "S"(top) also most of the time ends the script.
Simplest (and stupidest) solution so far:
set fit script "abcdef"
while (1) { fit ... }
ctrl-C
(S)top fit, (C)ontinue, (E)xecute FIT_SCRIPT: e
executing: abcdef
gnuplot> abcdef
^
line 5: invalid command
gnuplot>