How to Process Multiple Waves at Once

Hi, I am relatively new to Igor and also very new to coding in general. I'm learning right now about data processing and trying to build code for it. Basically, what I am trying to do, is take multiple waves (I believe I have at least 18) and make sure that when I click a button that all of them can be processed into one table at the same time. The point of the whole data processing is that within these 18 or so waves, I can set the boundaries for each one (math is already done for different data sets) and take the integral under the curve of each specific area to input into a new table (hopefully this all made sense).

My code is here: 

string current_wave
string time_wave
prompt current_wave, "Choose Data Wave", popup, Wavelist("*",";","")
prompt time_wave, "Choose Time Wave," popup, Wavelist("*",";","")
Doprompt "Select Wave", current_wave, time_wave
          if (V_flag)
                  return -1 //if there is a mistake and you want to go back
          end if
 
          NVAR /Z red_step=reduction //reduction refers to the local variable in the Def_Var function
          NVAR /Z pulse_width=pulse
          variable i
                  for (i=0; i<red_step; i+=1)

                          variable x=0 //resetting x and y, always equal to zero to restart the function
                          variable y=0

                          x=((pulse_width) + (1/2)*(pulse_width) + (2*pulse_width*i)) -1 //math to find the boundaries for each data set
                          y=((2*pulse_width) + (2*pulse_width*1)) -1


                          wave charges //beginning of integration step
                          redimension /N=(numpnts(charges)+1) charges //add row beneath each input
                          charges[numpnts(charges)-1]=areaXY($time_wave,$current_wave,x,y)
                  endfor
     

 

Apologies for any code that isn't lit up or that is and isn't supposed to be, it's my first time using the coding snippet. Anyway, what is above is for one single wave. If I click a button, the integration for the specific wave I chose will be input into my new table. But, this is tedious for many waves. 

I've looked at Listbox and I think it could be useful but I'm not sure. I also found another code from another forum that looks like this:

string prefixString //first part of name common to all waves
    variable firstNum //number of first wave in series
    variable lastNum //number of last wave in series
   
    variable n
    string currentWaveName
    for (n=firstNum; n<=lastNum; n+=1)
        sprintf currentWaveName, "%s%d", prefixString, n
       
        wave currentWave= $(currentWaveName)

I thought this may be useful because my waves have a similar start and similar end in their name, with different things in the middle. But, I do this and get lost in the code. I feel that I am very close. Any help would be greatly appreciated, and please let me know if I need to clarify anything I have said above. Thank you!

If you want to select a group of waves, the WaveSelectorWidget will turn a listbox into a wave selection control. Execute

DisplayHelpTopic "WaveMetrics Utility Procedures"

for more info.

If you're new to Igor coding, trying to make that work may be trying to run before you can walk. I strongly advise that you break your programing tasks into small, independent chunks of code that you can verify before moving on.

If you want to try out the WaveSelectorWidget, you need first to include the Wavemetrics file by adding #include <WaveSelectorWidget> to your procedure file.

Look in the procedure file WaveSelectorWidget.ipf for documentation.

Programmatically create a control panel and add a listbox and a button, use the MakeListIntoWaveSelector function to create the wave selector, have the button fire a function that grabs and prints the full paths of the selected waves. When that works, you can move on to writing an analysis function that takes a list of waves as input.

In reply to by tony

I thought this may be useful because my waves have a similar start and similar end in their name, with different things in the middle. 

Try

WaveList(matchStr, separatorStr, optionsStr )

This will return a string containing a list of waves in the current directory matching your naming convention.  You can then loop through this list.