home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Simtel MSDOS 1992 September
/
Simtel20_Sept92.cdr
/
msdos
/
editor
/
me_cd.arc
/
LOAD.MUT
< prev
next >
Wrap
Text File
|
1988-10-24
|
2KB
|
52 lines
;; load.mut : load with path search
;; Load a file, searching along a set of paths (in this case the paths
;; are held in a env var). The env var is list: each path is
;; separated by a ":" (UNIX) or ";" (MS-DOS) (see APATH below). Each
;; path elment is assumed to end with a "/". (If MS-DOS, the separater
;; can be a "\"). See the example below.
;; Notes:
;; If you want to search the current directory and the directory in the
;; ME env var, put "::" in the path or end the path with ":".
;; Don't put multiple paths in the ME env var because it will confuse
;; (load) and your init file probably won't be loaded, etc.
;; The directories are searched in order.
;; It is somewhat sleazy to have to use 2 env vars for load. If this
;; functionality is really needed, it should be built into ME but I
;; only see this being useful on multiuser or LANed systems and it
;; seems to work OK ...
;; Example: To search "/foo" and "/bar" use "MES=/foo/:/bar/". The
;; current directory is not searched, nor is the directory in $ME. To
;; include . and $ME, use "MES=/foo/:/bar/:" or "MES=:/foo/:/bar/" or
;; "MES=/foo/::/bar/".
;; C Durland 10/88
(const
;; RE to pick out a path:
APATH '\([^:]*\):' ;; '\([^:]*\):' for UNIX, '\([^;]*\);' for MS-DOS
PATH-ENV-VAR "MES" ;; env var that holds the path
)
(defun
load-with-path-search
{
(string path 200 fname 100)
(fname (ask "Load (with path search): "))
(path (getenv PATH-ENV-VAR))
(while TRUE
{
(arg-prefix 1) ; don't complain if not found (I'll do it myself)
(if (RE-string APATH path)
{ (if (load (concat (get-matched '\1') fname)) (done)) }
{
(if (load (concat path fname))
() ; TRUE
{ (msg 'Could not load "' fname '".') FALSE })
(done)
}
)
(path (substr path (+ 1 (strlen (get-matched '\1'))) 1000))
})
}
)