Searching names of the waves in memory

I've used Igor for a few years now, but I never needed to write much in the way of procedure code until recently. I'm still getting the hang of all the commands and syntax, but right now I'm stuck on something that should be rather simple.

So far, I've got a function that loads multiple data files, each with three columns of data, the names of which are the first element in the column. This seems to work just fine.

After loading all these files, the waves from each file are named something like this: AAA_XXX_1 ; BBB_XXX_1 ; CCC_XXX_1

The three waves from each file will all have the same XXX and ending number. In the end, I need to take two of these waves with the same XXX_1, fit them to a line, and output new waves with slopes and intercepts along with sigmas. But I don't think I'll have a problem with that once I can reference the proper waves by name.

For now, I'd really just like some help with calling the waves with the same XXX_1 from the "pile" of waves in memory.

I've tried using the WaveList command, but it never compiles correctly so I can't even see what the command does.

Any help will be greatly appreciated.
You have a few options here. If you want to process the code directly after loading it, you can use S_Wavenames (which is created after you use LoadWave to import data). this is a string list of the waves you just imported. To reference a wave from a string name, use the $ operator.

string stringname
wave w = $stringname


Wavelist works great but you'd need to know what to filter for first. otherwise you will get a list of ALL waves in the current datafolder. Not really useful when you only want to fit 2 of them.

Thanks, proland!

When you say "datafolder" do you mean the folder where the text files are stored or does it refer to the waves loaded into memory?

I realize now how I was misusing WaveList. It's not so much a command as it is a kind of reference. I was trying to use it as a direct command, but now I realize that I have to do something with it. Instead of:

WaveList ("*XYZ*",";","")

It has to be something like:

print WaveList ("*XYZ*",";","")

Now that I realize this, I think things will be easier.



And in a function you might have something like this *untested* and *uncompiled* code:
    String listofwaves = WaveList("*ABC*", ";", "")
    Variable i
    Variable nwaves = ItemsInList(listofwaves)
    for (i = 0; i < nwaves; i += 1)
        Wave w = $StringFromList(i, listofwaves)
        < do something with w>
    endfor


John Weeks
WaveMetrics, Inc.
support@wavemetrics.com
Data Folder refers to the folder in IGOR where waves/variables/strings are stored. The default is the root: folder but you can place your waves in any subfolder you create.

Run this code to see what I mean...

function example()
newdatafolder/o/s root:folder1
make wave1, wave2, wave3, apples
print wavelist("*", ";", "")                         //prints all waves in folder1
print wavelist("wave*", ";", "")                 //prints all waves starting with "wave" in folder1

setdatafolder root:
print wavelist("*", ";", "")                        //prints waves in root folder (none if this is run in a new experiment file)

newdatafolder/o/s root:folder2
make v1, v2, v3, j1, j2, j3
print wavelist("v*", ";", "")                      //print waves starting with v
print wavelist("j*", ";", "")                      //print waves starting with j

end


displayhelptopic "Data Folders"
Ah, thanks a lot for the code, johnweeks! This will help immensely.

Many thanks to you as well, proland.