next up previous contents
Next: FEVAL Evaluate a Function Up: FreeMat Functions Previous: EVAL Evaluate a String   Contents

Subsections

SOURCE Execute an Arbitrary File

Usage

The source function executes the contents of the given filename one line at a time (as if it had been typed at the --> prompt). The source function syntax is

  source(filename)

where filename is a string containing the name of the file to process.

Example

First, we write some commands to a file (note that it does not end in the usual .m extension):

--> fp = fopen('source_test','w');
--> fprintf(fp,'a = 32;\n');
--> fprintf(fp,'b = a;\n');
--> fclose(fp);

Now we source the resulting file.

--> clear all
--> source source_test
--> who
  Variable Name      Type   Flags             Size
              a     int32                    [1 1]
              b     int32                    [1 1]



Samit K. Basu 2005-03-16