
using original datafile names when loading waves thru LoadWave

vishivishi
Hello all, I am trying to name the waves created thru LoadWave using original names of the datafiles. I thought, I would use global $S_waveNames and $S_fileName in Duplicate to do so but it gives me an error Duplicate error: expected wave name. Any help is appreciated.
Thanks,
Vishi
Function CustomWaveSelect(fileName, pathName) String pathName // Name of Igor symbolic path or "" String filePath // Full path, partial path or file name if (V_Flag) return -1 // User canceled endif // Load the waves and set the local variables. LoadWave/M/J/D/O/P=$pathName fileName Duplicate/O $S_waveNames, $S_fileName if (V_flag==0) // No waves loaded. Perhaps user canceled. return -1 endif End
Here is how I would do it:
If your data contains just numbers (no NaNs, dates, text data), then I recommend using LoadWave/G instead of LoadWave/D. The reason is that LoadWave/G will find the data in the file, skipping any header information, whereas LoadWave/D needs to be told where (on what line) the data starts. However, if the file contains nothing but numbers, both LoadWave/G and LoadWave/D will work fine.
If you are not familiar with Igor symbolic paths, execute this to read the help:
February 17, 2012 at 10:59 am - Permalink
Great! Thanks so much. I've commentized /if (strlen(filePath) == 0) because I want it to loop thru the number of files the user chooses to plot/analyze and it works. A separate thanks for your bonus tips on how to clean the file name and strip it off the extension. Thanks a lot!
Vishi
February 17, 2012 at 11:40 am - Permalink