[To reply replace "Aaron.Sloman.XX" with "A.Sloman"]
A common problem: someone produces a library or package which consists
of a collection of files all of which need to be compiled by a single
"main" file. The user may always work in a particular directory and have
commands in the main file like:
load file1.p
load file2.p
load subdir/file3.p
etc.
Unfortunately this does not work for someone who is using another
directory. So a common strategy (e.g. by students) for getting round
this is to put absolute pathnames in:
load ~fredx/project/file1.p
load ~fredx/project/file2.p
load ~fredx/project/subdir/file3.p
etc.
Unfortunately this breaks when the files are moved to another location,
e.g. if project files are put in a library.
One solution is to add the relevant directories to popuseslist (using
extend_searchlist), and then use "lib" or "uses" commands to load
individual files. (See HELP USES, REF LIBRARY ).
A simpler solution is provided by a new autoloadable macro "compilhere",
now available with help file in
http://www.cs.bham.ac.uk/research/poplog/auto/compilehere.p
http://www.cs.bham.ac.uk/research/poplog/help/compilehere
It allows a file to simply include commands like:
compilehere
file1.p
file2.p
subdir/file3.p
;
The definition is very simple:
define macro compilehere();
lvars
file,
;;; Get pathname for THIS directory
thisdir = sys_fname_path(popfilename);
;;; Make the lexical analyser return newlines as words.
dlocal popnewline = true;
;;; ignore rest of line
rdstringto([; ^newline]) -> file;
;;; Now read file names and plant code to compile them.
;;; Stop when a line is empty or contains only a semi-colon.
repeat;
rdstringto([; ^newline]) -> file;
quitif(file = nullstring);
"pop11_compile","(",thisdir dir_>< file,")",";"
endrepeat;
enddefine;
(It could have been defined as a syntax word, but the above is
probably simpler and clearer.)
Aaron
--
Aaron Sloman, ( http://www.cs.bham.ac.uk/~axs/ )
School of Computer Science, The University of Birmingham, B15 2TT, UK
EMAIL A.Sloman AT cs.bham.ac.uk (NB: Anti Spam address)
TOOLS: http://www.cs.bham.ac.uk/research/poplog/freepoplog.html
|