loading several files

Hi, i'm not so confident with IgoPro (my version 4.0.5.1 -old, I know) and i am trying since a long time to write a macro (or a function) to import several *.dat files (all in the same repertory).
I have tested several macro but none is working.
my files are *.dat and compose in 3 columns with a text header. My objectives is just to import all the dat files each in a datafolder, ideally with the file name.
Is there anything allready writen to do that? of course there is a post treatment of my data, but the macro I wrote is working (but works by file by file, and some times I have tens of files...)
thank for help or advices
Ludovic

ps: example of files
VGS Id@VDS=NaN Ig@VDS=NaN
1.00000E+0 2.55214E-3 -7.40290E-12
9.75000E-1 2.84232E-3 4.16636E-11
9.50000E-1 2.80483E-3 4.01139E-11
9.25000E-1 2.73276E-3 4.15683E-11
9.00000E-1 2.65699E-3 3.90291E-11
8.75000E-1 2.57470E-3 4.22239E-11
8.50000E-1 2.50296E-3 4.05788E-11
8.25000E-1 2.42457E-3 4.04000E-11
8.00000E-1 2.35374E-3 4.63009E-11
7.75000E-1 2.28333E-3 4.51803E-11
7.50000E-1 2.20682E-3 4.58121E-11
7.25000E-1 2.13451E-3 4.70042E-11
7.00000E-1 2.06123E-3 4.39048E-11
6.75000E-1 1.98412E-3 4.64082E-11
6.50000E-1 1.91094E-3 4.15087E-11
Hi,

this should work, at least in Igor 6 - The LoadWave command may need some adjustment according to the structure of your *.dat files.

Function FileImport()
   
    NewPath/O PathName  //prompt for folder in which the files are
       
    if (V_flag == -1)   //User cancelled dialog
        return -1
    endif
   
    string ListOfFiles = IndexedFile(PathName, -1, ".dat")  // Get list of *.dat files in folder
    String CurrentFile = ""
    variable i
   
    do
        CurrentFile = StringFromList(i, ListOfFiles)           
        if(strlen(CurrentFile)==0)  // no more file to import
            break
        endif
       
        NewDataFolder/O/S $CurrentFile   //make new datafolder
       
        LoadWave/A/D/J/W/K=0/V={" "," $",0,0}/L={0,1,0,0,0}   /P=PathName CurrentFile
        SetDataFolder ::
        i+=1
    while(1)
end


Cheers
Christian
Hi Christian,

I will find in my lab the V6 and try as soon as possible the function you sent me.

thanks a lot

Ludovic (a beginner)