[Maxima] How to open a file given its pathname relative to the current batch script

Robert Dodier robert.dodier at gmail.com
Mon Nov 23 16:26:57 CST 2009


On Mon, Nov 23, 2009 at 2:14 PM, Manuel Fiorelli
<manuel.fiorelli at gmail.com> wrote:

> I wrote a batch script where I need to read some data from a file
> (using "numericalio"). I'd like to specify
> the pathname relative to the batch file, so that I can relocate the
> script and the companion files.

Try this: append the path to file_search_maxima, then call file_search
to return the path for the data file.

e.g.

file_search_maxima : cons ("/my/path/###", file_search_maxima);
file_search ("my.data");
 => /my/path/my.data
read_list (file_search ("my.data"));
 => (stuff)

In the search path, "###" matches any file name.

Incidentally with /my/path in the search path, batch("foo.mac")
and load("foo.mac") automatically search /my/path for foo.mac.

HTH

Robert Dodier


More information about the Maxima mailing list