P or X used outside of a wave assignment loop.

I am attempting to execute a procedure file, however during compilation I receive the error "P or X utilised outside of a wave assignment loop."

The error is not displayed after setting SetIgorOption FuncOptimize, CatchIllegalPandX= 0; however, I did not observe that the function executed.


I am including the procedure file as a resource.

PARGAN_model_vpk.ipf (96.75 KB)

The code has more indexing issues than just using p or x in the wrong place.

For example:

wave growth
    IF(growth > 300 || growth < -300)
        growth=NAN    
    ENDIF

if you want to set the out-of-bounds points to NaN, it is done like this:

growth = growth>300 || growth<-300 ? NaN : growth

DisplayHelpTopic "Understanding Wave Assignments"

The code will need to be debugged.