I would suspect H L C are undefined. My general approach is to
insert smoutput before and after every control switch, eg
smoutput 'a1'
for_i. i.(#a) do.
smoutput 'a2'
currHi=. ". > (i { H)
currLo=. ". > (i { L)
currCl=. ". > (i { C)
if. (0=i) do.
smoutput 'a3'
diffHi=. 0
diffLo=. 0
else. <-------- control error here
smoutput 'a4'
prevHi=. ". > ((i-1) { H)
prevLo=. ". > ((i-1) { L)
diffHi=. currHi - prevHi
if. 0<:diffHi do. pivotHi=. currHi end.
smoutput 'a5'
diffLo=. prevLo - currLo
if. 0<:diffLo do. pivotLo=. currLo end.
smoutput 'a6'
end.
smoutput 'a7'
if. diffLo>diffHi do.
smoutput 'a8'
if. currLo <: ( pivotHi * (1-swing) ) do.
smoutput 'a9'
xx=. xx , currLo
Втр, 21 Фев 2012, PackRat писал(а):
> When loading a script to test, I get an immediate "control error" when
> I give the command to load it. The following is the portion of the
> script that has all of the control structures. I've drawn an arrow
> pointing to the line where the error is supposed to have occurred. I'm
> probably "blind" to the error because I'm just not seeing the problem.
>
> ================================================================
>
> for_i. i.(#a) do.
>
> currHi=. ". > (i { H)
> currLo=. ". > (i { L)
> currCl=. ". > (i { C)
>
> if. (0=i) do.
> diffHi=. 0
> diffLo=. 0
> else. <-------- control error here
> prevHi=. ". > ((i-1) { H)
> prevLo=. ". > ((i-1) { L)
> diffHi=. currHi - prevHi
> if. 0<:diffHi do. pivotHi=. currHi end.
> diffLo=. prevLo - currLo
> if. 0<:diffLo do. pivotLo=. currLo end.
> end.
>
> if. diffLo>diffHi do.
> if. currLo <: ( pivotHi * (1-swing) ) do.
> xx=. xx , currLo
> else.
> xx=. xx , ( {: xx ) NB. repeat previous value
> end.
> else.
> if. currHi >: ( pivotLo * (1+swing) )
> xx=. xx , currHi
> else.
> xx=. xx , ( {: xx ) NB. repeat previous value
> end.
> end.
>
> end.
>
> ================================================================
>
> The same error (at the same line) occurs if the following lines:
>
> if. 0<:diffHi do. pivotHi=. currHi end.
> . . .
> if. 0<:diffLo do. pivotLo=. currLo end.
>
> are instead expanded to:
>
> if. 0<:diffHi do.
> pivotHi=. currHi
> end.
> . . .
> if. 0<:diffLo do.
> pivotLo=. currLo
> end.
>
>
> I would appreciate any assistance in "opening my eyes"--thanks in
> advance!
>
>
> Harvey
>
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
--
regards,
====================================================
GPG key 1024D/4434BAB3 2008-08-24
gpg --keyserver subkeys.pgp.net --recv-keys 4434BAB3
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm