[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
m-file knowing its own source location?
From: |
forkandwait |
Subject: |
m-file knowing its own source location? |
Date: |
Fri, 19 Mar 2010 03:36:45 +0000 (UTC) |
User-agent: |
Loom/3.14 (http://gmane.org/) |
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
- m-file knowing its own source location?,
forkandwait <=