|
From: | Carlo de Falco |
Subject: | Re: m-file knowing its own source location? |
Date: | Fri, 19 Mar 2010 06:51:24 +0100 |
On 19 Mar 2010, at 04:36, forkandwait wrote:
Hi all,Is there a way for an m-file to reference its source code location in the filesystem? Note that I am not asking about referencing the current workingdirectory, but rather the directory where the m source is stored.So that if I store foo.m in /home/forkandwait/mfuncs/foo.m, but my current working directory is /home/forkandwait, I can still get foo to know it isstored in mfuncs?
try 'help mfilename'
The reason is that I want to write a bunch of data access functions and store them in the same dir as the data, then genpath addpath to get them. However, I also want to avoid hardcoding pathnames. This way, usapopulation() will always know to look "next" to where its source code is stored to read in a file called usapopulation.txt, munge it, and return various useful matrices; usapop() willbe able to do this no matter where the octave interpreter is running. If this seems like a bad pattern, let me know that too. Thanks again F&W
c.
[Prev in Thread] | Current Thread | [Next in Thread] |