What Im actually trying to do is to re arrange a previous code to make work with some other scripts I developed but it is in fortran and I'm having a hard time translating it.
DIMENSION E(50)
N=0
1 N=N+1
CALL DATA(E(N),K)
IF(K == 1) STOP
2 IF(N < 3) GO TO 1
X=ABS((E(N)-E(N-1))
Y=ABS(E(N-1)-E(N-2))
3 IF(X.LT.Y) GO TO 1
4 RANGE=Y
XMEAN=(E(N-1)+E(N-2))/2
N=N-2
E(N)=E(N+2)
GO TO 2
END