Problems with "Index out of range"?
cdc
Function Example()
make/o/n=100 w1
make/o/n=80 w2
w1 = x^2
w2 = sqrt(x)
w1[] = w2[p]
end
If I run this I get an index out of range error. If I change this to
Function Example()
make/o/n=100 w1
make/o/n=80 w2
w1 = x^2
w2 = sqrt(x)
w1[0,numpnts(w2)-1] = w2[p]
end
then everything is fine (of course). I understand that this latter approach is better because there is no ambiguity in the indexing. But I am wondering if something has changed to cause Igor to give errors more often when I have my indexing wrong.
Thanks!
Read all about the ramifications (which includes the "Index out of range" checking), in your "What's Changed Since 6.1" help file, and scroll down to 6.30's "Changed Behavior" section.
To read about the "Changed Behavior" on the web:
http://www.wavemetrics.com/products/igorpro/newfeatures/whatsnew63.htm
--Jim Prouty
Software Engineer, WaveMetrics, Inc.
March 27, 2013 at 12:32 pm - Permalink
Ex. (adapted from above)
w1[0 + 10, numpnts(w2) - 1 +10] = w2[p]
How can I avoid the index out of range error?
Thanks!
January 26, 2014 at 10:23 pm - Permalink
p is going from 10 up to and including (numpnts(w2)-1+10).
Probably you mean to write:
so that the indices used to index w2 go from 0 to (numpnts(w2)-1).
January 26, 2014 at 10:32 pm - Permalink
January 26, 2014 at 10:49 pm - Permalink