Executing the RUN Command


To execute an external program, use the RUN function. For example, to run a text editor from within a Worksheet, you might type:











Notice that the program names are surrounded by double quotes (" ").



The following is a simple command to identify all the data files in the current directory, write the listing of them to a file, and view the file in the DADiSP Worksheet:


run("dir /B *.dat > mydata.txt",-1);viewfile("mydata.txt")


Setting the second argument to the run command to negative one ( -1) causes DADiSP to wait until the command (in this example, dir /B *.dat > mydata.txt) has completed execution. After the file, mydata.txt, is created, it is displayed in the Worksheet via the viewfile function.


You can also use the DADiSP Pipeline to help automate the import process when you have many raw data files to import with DADiMP (DADiSP's stand-alone import utility). In this example, the data file names and header file names increment numerically for each test.


Data File Associated Header File


data1.dat test1.hed

data2.dat test2.hed

data3.dat test3.hed


The SPL function below, ImpExample, uses the RUN command to execute DADiMP and import the data files. After loading the SPL file into the Worksheet (use Tools, SPL, Read SPL File), use this command to execute at the command line:


ImpExmp1("data", "test", 3)


This is the SPL function:


ImpExample(datafile, hedfile, numfiles)


    local dfile, hfile, dstr, j;



     * datafile:  the core string for the data filename

     * hedfile:   the core string for the header filename

     * numfiles:  the number of files to import


     * the filenames increment by 1

     * this SPL pieces together the data file name,

     * the header file name, and the string for the

     * command using SPRINTF, then calls the RUN command


     * The second argument to RUN (-1) tells DADiSP to

     * wait until the import is complete before continuing



    for (j = 1; j <= numfiles; j++)


        dfile = datafile + strnum(j) + ".dat";

        hfile = hedfile  + strnum(j) + ".hed";

        dstr  = sprintf("DADiMP -L=%s -H=%s %s",

                    getlabname, hfile, dfile);


        // run the command to import

        run(dstr, -1);