A more succinct way of referencing the last element of a wave

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.

niallrobinson wrote:
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?

thanks
Niall
niallrobinson wrote:
I totally forgot you could reference using negative numbers to go back from the end.


That would be Python, I don't think Igor has that
Make /N=100 test = x
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.
oh yeh - I miss read what you had said, that *is* python. Well, in that case, my first point stands, igor could do with a similar system I think.

Niall