batch file loader causing igor to crash

I modified a batch file loader from the forums to load tab delimitated text files. Each file is approx 3MB. I first tired using it to load a full data set(500 files) and igor froze, so then I tried to load a smaller set, 10 files, and it still crashes. Here is the code below, if someone has an idea, or a way to get it to stop freezing that would be awesome!


Function LoadAllFilesFromFolder(pathName)
    String pathName             // Name of an Igor symbolic path or "" to get a dialog
 
    if (strlen(pathName) == 0)
        NewPath/O/M="Choose a folder containing TIFFs" LoadIndexedFilePath
        if (V_flag != 0)
            return -1               // User cancelled
        endif
        pathName = "LoadIndexedFilePath"
    endif
 
    String fileName
    Variable index
 
    index = 0
    do
        fileName = IndexedFile($pathName, index, "TEXT")
        if (strlen(fileName) == 0)
            break           // No more files.
        endif
 
        LoadWave /J/M /P=$pathName fileName
 
        index += 1
    while (1)
End
<pre><code class="language-igor">
Please send a zip archive containing whatever we need to reproduce the problem to WaveMetrics support. Include any instructions and let us know what operating system and Igor version you are using.

One data file should be sufficient - we can duplicate it 10 times here. But verify that the crash occurs if you duplicate that data file 10 times and run your procedure before sending it as we need to reproduce the problem in order to fix it.

I have attached one of the data files for you in zip format. I am using igor pro 6.22A on a macbook pro laptop running OS 10.6.8.
0.zip (598.48 KB)
I downloaded your file and unzipped it. This gave a file named "0". This file was not recognized as a TEXT file by this line in the procedure:
    fileName = IndexedFile($pathName, index, "TEXT")

so no files were loaded.

I changed the file name from "0" to "Data0.txt" and duplicated the file 9 times creating "Data1.txt", "Data2.txt" and so on.

I also changed "TEXT" in the procedure to ".txt" to make sure it found the .txt files.

I also added this to the loop so I could see what is going on:
    Print index, fileName


I then executed LoadAllFilesFromFolder(""), chose the folder containing the files, and all of the files were loaded.

I got no hang or crash.

In order to further investigate I need step-by-step instructions for creating the problem.

I'm running Igor Pro 6.22A on Mac OS X 10.6.3.


I tried what you did and it worked fine. It seems that igor doesn't like the coding for extensionless files. Is there a work around, or do I have to add extensions to hundreds of files? which would suck
I don't get a hang or crash running the procedure on a folder containing files with no extension. Nothing loads however because no extension does not match the last parameter passed to IndexedFile.

Perhaps your problem is caused by other files in the folder other than the data files. Try removing all other files.

Here is code that will load all files with no extension and will skip files with an extension. Make sure that all files in the folder with no extension are in fact data files.

Function LoadAllFilesFromFolder(pathName)
    String pathName             // Name of an Igor symbolic path or "" to get a dialog
 
    if (strlen(pathName) == 0)
        NewPath/O/M="Choose a folder containing data files" LoadIndexedFilePath
        if (V_flag != 0)
            return -1               // User cancelled
        endif
        pathName = "LoadIndexedFilePath"
    endif
 
    String fileName
    Variable index
 
    index = 0
    do
        fileName = IndexedFile($pathName, index, "????")        // All files
        if (strlen(fileName) == 0)
            break           // No more files.
        endif
       
        String extension = ParseFilePath(4, fileName, ":", 0, 0)
        if (strlen(extension) == 0) // Load only if file has no extension
            Print index, fileName
            LoadWave /J/M /P=$pathName fileName
        endif
       
        index += 1
    while (1)
End