On Tue, 23 May 2017, Sven Schreiber wrote:
Am 22.05.2017 um 23:06 schrieb Allin Cottrell:
> I think I found the problem: on repeated errors in a loop, "catch" could
> stop working (that is, fail fully to nullify the error condition).
>
> I show below an example which did not work properly before, but which now
> does. Hopefully it exhibits the same problem as you found; if so the issue
> is fixed in git.
A fix is always good, of course. However, I believe that my debug
output showed that the problem occurs when $error is non-zero for
the first time already. I should perhaps mention that this is
happening within a function, and (I think) the lag order parameter
should stay constant for each function call. So I believe the
following sequence of events applies roughly:
- function is executed, inside it we have "catch var..." working but not
reacting because everything is perfectly valid
- this happens many times, first because the "catch var" is also inside a
loop, and secondly because the function is called repeatedly
- then the same function is called with invalid lag order 0, and at the first
loop iteration "catch var..." should set $error to non-zero.
- But instead of executing the "if err ... endif" block correctly (and
perhaps failing afterwards), I got the unpaired-if error.
Here's an attempt to replicate what you describe (where the error
condition is provoked in a loop in a function that is called from
within a loop); it works OK with current git.
<hansl>
set verbose off
function scalar dovar (list L, int p)
loop j=1..4 -q
printf "dovar: p=%d, j=%d\n", p, j
catch var p L --silent
err = $error
if err
printf "Problem, err = %d\n", err
endif
print "dovar, still going..."
endloop
return 0
end function
open data9-7 -q
list L = QNC PRIME UNEMP
matrix p = {1,0,2} # zero in position 2
loop i=1..3 -q
printf "main: i=%d\n", i
result = dovar(L, p[i])
print "main, still going..."
endloop
</hansl>
If this works for you too but your original script does not, please
send me the failing script.
Allin