Exporting multiple 2D waves

Hi all,
Basically, I'd like to export N-2D waves of an experiment into N-text files. Of course, I can just open the wave table, copy the 2 columns and past into a text file, but it is getting intense when I have few hundreds of waves.
I did some coding in the past, but I am totally new to Igor, so any help and advice will be much appreciated. Thanks!
Below is a routine that saves all 2D waves in the current data folder to disk.

But first . . .

If you are not familiar with the important concept of Igor symbolic paths, execute this and read the corresponding help:
DisplayHelpTopic "Symbolic Paths"


If you are not familiar with the important concept of Igor data folders, execute this and read the corresponding help:
DisplayHelpTopic "Data Folders"


Also, if you have not already done it, do the first half of the Igor Guided Tour which you can find by choosing Help->Getting Started.

Here is the routine:

Function/S SaveAllNumeric2DWaveToTextFiles(pathName)
    String pathName     // Name of Igor symbolic path
   
    String fileNameList = ""
   
    Variable index = 0
    do
        Wave/Z w = WaveRefIndexed("", index, 4) // Next wave in current data folder
        if (!WaveExists(w))
            break               // No more waves
        endif
       
        if (WaveType(w) == 0)
            index += 1
            continue            // Skip text waves
        endif
        if (WaveDims(w) != 2)
            index += 1
            continue            // 2D waves only
        endif

        String fileName = NameOfWave(w) + ".dat"
        Save /P=$pathName /J /O w as fileName   // Save to text file
        fileNameList += fileName + ";"
       
        index += 1
    while(1)
   
    return fileNameList
End

Hi again there and thanks for the helpful code. I just have two quick questions:
First, I'd like to name my text files 1.dat, 2.dat, 3.dat etc. Is there away to convert an Integer into a String? (7th line from the end)
And second, to make the code work, I need to load my waves. Is there a way to load, let say 50 waves in the same time?

//Code provided by Igor-Exchange, user "hrodstein" 11/30/2011:
             //Save 2D waves to text files *.dat
//Modified by Vireak Yim 12/02/2011:
            // Extract points from waves, rearrange them into 2 columns, and save in a text file *.dat


Function/S SaveAllNumeric2DWaveToTextFiles(pathName)
    String pathName     // Name of Igor symbolic path
 
    String fileNameList = ""
 
    Variable index = 0
    do
        Wave/Z w = WaveRefIndexed("", index, 4) // Next wave in current data folder
        if (!WaveExists(w))
            break               // No more waves
        endif
 
        if (WaveType(w) == 0)
            index += 1
            continue            // Skip text waves
        endif
        if (WaveDims(w) != 2)
            index += 1
            continue            // 2D waves only
        endif
       
       
        Make /N = (199,3)  Subwave     // Create an intermediate wave with 200 rows
        Variable ind = 0
        do
            Subwave[ind][0] = w[ind][2]*10^9
            Subwave[ind][1] = w[ind][0]*10^9    // Rearrange the data columns and convert them to nm to fit the pointwise requirements
            Subwave[ind][2] = w[ind][1]*10^9   
               ind += 1  
        while(ind<200)
       
        String fileName = %index + ".dat" // Convert integer 'index' into string (trying to get 1.dat, 2.dat, 3.dat...)
        Save /P=$pathName /J /O Subwave as fileName // Save to text file
        fileNameList += fileName + ";"
 
        index += 1
    while(1)
 
    return fileNameList
End

Cheers,
mssmtrainee wrote:
First, I'd like to name my text files 1.dat, 2.dat, 3.dat etc. Is there away to convert an Integer into a String? (7th line from the end)

Sure, it's num2istr.

mssmtrainee wrote:
And second, to make the code work, I need to load my waves. Is there a way to load, let say 50 waves in the same time?

Maybe you can start by modifying this function posted by Adam Light.

A
Quote:
Is there a way to load, let say 50 waves in the same time?


Execute this:

DisplayHelpTopic "Loading Waves Using Igor Procedures"