Name of wave and wave scalling

Hi all,
I'm beginner in IGOR and working on analysing of data of photoemission spectra. I have a lot of files and I am making merging all of these files into one 2D matrix. There are information about this spectrum (for example name of transition, excitation energy) and two columns in source files: energy (axis X) and intensity (axis Y).
There are two main problem: automatically title wave by text from source file(I don't know how I can read string variable from source file);
set scale (X) by first column from source file(As I know it's impossible with function SetScale)

Does anybody know solving for these problems?
Thanks in advance!
Quote:
I'm beginner in IGOR and working on analysing of data of photoemission spectra.

If you have not already done it, do the Igor Pro Guided Tour. It is indispensible. Choose Help->Getting Started.

Quote:
I don't know how I can read string variable from source file

Most likely you will have to read the title using FReadLine. For an example see http://www.igorexchange.com/node/908.

Quote:
set scale (X) by first column from source file(As I know it's impossible with function SetScale)

If I understand correctly you would want to load the first column into a numeric wave. Then:
String xName = StringFromList(0, S_waveNames);  // S_waveNames is set by LoadWave
String yName = StringFromList(1, S_waveNames);  // S_waveNames is set by LoadWave
Wave xw = $xName  // Create wave reference for X wave
Wave yw = $yName  // Create wave reference for Y wave
Variable x0 = xw[0]
Variable dx = xw[1] - xw[0]
SetScale/P x x0, dx, "units", yw  // Change "units" to whatever is appropriate for your data
KillWaves xw  // We no longer need the X wave

Thank you very much!
And once more question about title. Just Iwant to load strint from first line of this file (see attached). Only "In 4d", without "# Transition ". And use this text like title of new wave.

I use this code:
SetDataFolder root:ARGUS:Load_Files
FolderName=FolderName+stFileName+stFileName1
Open/R/P=$FolderName RefNum
FReadLine/N=45 RefNum, NameCoreLevel
Close RefNum
end
a2.txt
The way I taught myself was to use the built in point and click methods and see what the commands did.

Looking at your text file. You can break up the problem into two parts:
1. Reading the important header info
2. Readings the data in.

For your question about the the header info you want one way to do this is to treat the header portion as an import as text wave and you can read in that portion. Once you have that in you can manipulate the text string to what you wan to extract. If for example the formatting is always the same then you can trim the text the needed number of characters from the beginning. Take off the first 35 characters and you are left with In 3d5/2.

Then run a second load wave function that pulls in only the data.

While maybe not the most compact and elegant approach I have found it useful in my learning to break apart the problem and emulate what the point and click process does to help me learn.
Here is how I would do it:
#pragma rtGlobals=3     // Use modern global access method and strict wave access.

// Add an item to Igor's Load Waves submenu (Data menu)
Menu "Load Waves"
    "Load Sergey Text File...", LoadSergeyTextFile("", "")
    "Load All Sergey Text Files In Folder...", LoadAllSergeyTextFiles("")
End

Function GetWaveNames(refNum, xName, yName)
    Variable refNum
    String &xName               // Output
    String &yName               // Output
   
    xName = "tempXWave"             // X wave will be killed after scaling is set on y wave
   
    String text, format
   
    // Read file name from first line of file
    FReadLine refNum, text              // Read first line
    format = "# Transition %[^/]"       // Skips "# Transition " reads text until slash"
    sscanf text, format, yName          // Extract y wave name
   
    // Clean up y wave name so it is a standard Igor name as liberal names are harder to program with
    yName = CleanupName(yName, 0)
       
    return 0
End

//  LoadSergeyTextFile(pathName, fileName)
//  Loads y wave into current data folder.
//  NOTE: If the wave already exists in the current data folder, it is overwritten.
//  pathName is the name of an Igor symbolic path or "".
//  fileName is one of the following:
//      The name of a file in the folder designated by pathName.
//      A partial path from the folder designated by pathName to the file to be loaded.
//      A full path to the file to be loaded.
//      "" to get an Open File dialog.
//  The required file name extension is ".txt".
Function LoadSergeyTextFile(pathName, fileName)
    String pathName         // Igor symbolic path name or "" for dialog.
    String fileName             // file name, partial path and file name, or full path or "" for dialog.
   
    Variable err

    // This puts up a dialog if the pathName and fileName do not specify a file.
    String message = "Select a Sergey text file"
    Variable refNum
    String fileFilters = "Sergey Text Files (*.txt):.txt;"
    Open /R /Z=2 /P=$pathName /F=fileFilters /M=message refNum as fileName
   
    // Save outputs from Open in a safe place.
    err = V_Flag
    String fullPath = S_fileName

    if (err != 0)
        return err          // -1 means user canceled.
    endif
   
    String xName, yName
    err = GetWaveNames(refNum, xName, yName)
    // Print xName, yName   // For debugging only

    Close refNum

    if (err != 0)
        return err          // Error in GetWaveNames
    endif
   
    String columnInfoStr = ""
    columnInfoStr += "N='" + xName + "';"
    columnInfoStr += "N='" + yName + "';"
   
    // Load the data using Load General Text (/G)
    LoadWave /G /A /O /D /B=columnInfoStr /Q fullPath

    Wave xWave = $xName
    Wave yWave = $yName
   
    // Set X scaling
    Variable x0 = xWave[0]
    Variable dx = xWave[1] - xWave[0]
    SetScale/P x x0, dx, "nm", yWave    // Change "nm" to whatever is appropriate for your data
   
    KillWaves/Z xWave                   // X wave is no longer needed
   
    Printf "Loaded %s\r", yName

    return 0            // Zero signifies no error.
End

//  LoadAllSergeyTextFiles(pathName)
//  Loads all .txt into the current data folder.
//  NOTE: If a wave already exists, it is overwritten.
//  See LoadSergeyTextFile documentation above for details.
Function LoadAllSergeyTextFiles(pathName)
    String pathName // Name of an Igor symbolic folder created by Misc->NewPath
   
    if (strlen(pathName) == 0)
        String message = "Select a directory containing only Sergey data files"
        NewPath/O/M=message SergeyDataPath      // This displays a dialog in which you can select a folder
        if (V_flag != 0)
            return V_flag                           // -1 means user canceled
        endif
        pathName = "SergeyDataPath"
    endif
   
    Variable err = 0

    String fileName
    Variable i = 0
    do
        fileName = IndexedFile($pathName, i, ".txt")
        if (strlen(fileName) == 0)
            break                                       // No more files
        endif
   
        err = LoadSergeyTextFile(pathName, fileName)
        if (err != 0)
            return err
        endif
   
        i += 1
    while(1)
   
    return 0
End