Load Waves and Append

//  LoadWavesAndAppend(pathName, fileName)
//  Loads waves from the specified file into a temporary data folder.
//  Then, if the waves already existed in the original current data folder, this routine
//  appends the new data to the old waves.
//  If the waves did not already exist, it just moves the new waves into the original current data folder.
//  Returns the number of waves loaded.
//  You will need to customize this routine by using the LoadWave flags appropriate for your files.
//  pathName is the name of an Igor symbolic path. If you pass "" for it Igor will display an Open File dialog.
//  If you don't want a dialog you must create the symbolic path before calling this function.
//  If you are not familiar with Igor symbolic paths, execute this for help:
//      DisplayHelpTopic "Symbolic Paths"
Function LoadWavesAndAppend(pathName, fileName)
    String pathName     // Igor symbolic path name or "" for dialog.
    String fileName         // File name or "" for dialog.
    DFREF dfSave = GetDataFolderDFR()
    NewDataFolder/O/S tempLoad      // Load new waves in here.
    LoadWave/P=$pathName/J fileName
    if (V_flag <= 0)
        SetDataFolder dfSave
        KillDataFolder :                    // Kill tempLoad data folder.
        return 0            // Cancel
    // Now append the loaded waves to like-named waves in the parent data folder.
    Variable numWavesLoaded = 0
    String list = S_waveNames           // List of loaded waves.
    Variable i = 0
        String name = StringFromList(i, list)
        if (strlen(name) == 0)
            break                       // No more
        Wave wNew = $name
        String twin = "::" + PossiblyQuoteName(name)        // Path to like named wave in parent data folder.
        Wave/Z wOld = $twin
        if (WaveExists(wOld))
            Variable oldPoints = numpnts(wOld)
            Variable newPoints = numpnts(wNew)
            InsertPoints oldPoints, newPoints, wOld
            if (WaveType(wOld) == 0)        // Text wave?
                Wave/T tNew = $name
                Wave/T tOld = $twin
                tOld[oldPoints, oldPoints+newPoints-1] = tNew[p-oldPoints]
                wOld[oldPoints, oldPoints+newPoints-1] = wNew[p-oldPoints]
            // Wave does not exist in parent data folder.
            MoveWave wNew, ::           // Move into parent data folder.
        numWavesLoaded += 1
        i += 1
    KillDataFolder :                        // Kill tempLoad data folder.
    SetDataFolder dfSave
    return numWavesLoaded




Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More