[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: m-file knowing its own source location?
From: |
Jaroslav Hajek |
Subject: |
Re: m-file knowing its own source location? |
Date: |
Fri, 19 Mar 2010 06:51:27 +0100 |
On Fri, Mar 19, 2010 at 4:36 AM, forkandwait <address@hidden> 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 working
> directory, 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 is
> stored in mfuncs?
>
> 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() will
> be 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
>
help mfilename
--
RNDr. Jaroslav Hajek, PhD
computing expert & GNU Octave developer
Aeronautical Research and Test Institute (VZLU)
Prague, Czech Republic
url: www.highegg.matfyz.cz