Wavelist

The Wavelist function appends a semicolon to the wave name in the list. Is there a way to stop this from happening? 

Ok, I found another way to get what I want.

Genwave = stringfromlist(0,Wavelist("RT*",";",""))
Instead of
Genwave = Wavelist("RT*",";","")

Your solution is the best one, since WaveList is designed to return a list of items separated by some character or string. But it turns out that WaveList doesn't insist that the separator string have anything in it. So if you pass "" as the separator you get what you want. But if you have two waves that satisfy the match string, then you get two wave names smooshed together.

Genwave = stringfromlist(0,Wavelist("RT*",";",""))

This is potentially dangerous code from a performance perspective. It's fine now, but if you were to later decide that you need to call StringFromList in a loop and made the simplest obvious change to

Genwave = stringfromlist(n,Wavelist("RT*",";",""))

where n is your loop iterator, now you have poorly performing code if you have a lot of waves in the current data folder and/or n gets very large.

If you only need to remove a trailing semicolon, you can use RemoveEnding instead of StringFromList.

If there's any possibility that you would have more than one wave named "RT*" in the current data folder, you might want to rethink your approach. The WaveList documentation does not specify the order in which waves are returned, so you should not rely on any particular order. In practice the order is unlikely to change, but the current implementation returns waves in the order in which they were added to the current data folder, which is probably not the order you would expect.

 

Thank you both for the insight. There will never be another RT* wave in any one folder. Using double quotes as the separtor string is a good tip. Remembering that the waves may not be listed in the same order is important to remember. Thanks.

 

S