This may very well exist for all I know, but I would love a simple way of referencing the last element of an array. I'm tired of typing exampleWave[numpnts(exampleWave)] instead of something like exampleWave[>] or whatever.
I'm tired of typing exampleWave[numpnts(exampleWave)].
Ooh, naughty :-). exampleWave[numpnts(exampleWave)] will result in an error if you have rtglobals=3, which I suggest you use for all code development. I used to think rtglobals=3 was a pain, but I've picked up lots of bugs in my code this way.
You should be using
exampleWave[numpnts(exampleWave) - 1]
for the last point. If you don't have rtglobals=3 you can use:
examplewave[inf]
But there is no shortcut unfortunately. Python array indexing (and slicing) is something that I've always liked, pity Igor couldn't be more like it.
amazing - this is going to increase my productivity by at least 100%. I totally forgot you could reference using negative numbers to go back from the end. I've been doing it that way for ages and have never generated an error. What does the rtglobals setting do? And why is it best to set it to 3?
Ooh, naughty :-). exampleWave[numpnts(exampleWave)] will result in an error if you have rtglobals=3, which I suggest you use for all code development. I used to think rtglobals=3 was a pain, but I've picked up lots of bugs in my code this way.
You should be using
for the last point. If you don't have rtglobals=3 you can use:
But there is no shortcut unfortunately. Python array indexing (and slicing) is something that I've always liked, pity Igor couldn't be more like it.
July 28, 2011 at 01:03 am - Permalink
thanks
Niall
July 27, 2011 at 02:41 pm - Permalink
That would be Python, I don't think Igor has that
Print test[numpnts(test) - 1] // prints '99'
Print test[-1] // prints '0'
In rtGlobals=1 the index is basically clipped. rtGlobals=3 throws an error.
July 27, 2011 at 02:55 pm - Permalink
Niall
August 1, 2011 at 10:42 pm - Permalink