Node:General Search Paths, Previous:Source Search Paths, Up:Search Paths
Your application may need to search files in several directories, like
included does. To facilitate this, Gforth allows you to define
and use your own search paths, by providing generic equivalents of the
Forth search path words:
Look in path path-addr for the file specified by addr1 u1. If found, the resulting path and and (read-only) open file descriptor are returned. If the file is not found, ior is non-zero.
open-path-fileaddr1 u1 path-addr -- wfileid addr2 u2 0 | ior gforth ``open-path-file''
path-allotumax -- unknown ``path-allot''
Allota path with umax characters capacity, initially empty.
Set the path path-addr to empty.
clear-pathpath-addr -- gforth ``clear-path''
add the directory c-addr len to path-addr.
also-pathc-addr len path-addr -- gforth ``also-path''
Display the contents of the search path path-addr.
.pathpath-addr -- gforth ``.path''
Add the directory dir to the search path path-addr.
path+path-addr "dir" -- gforth ``path+''
Make a complete new search path; the path separator is |.
path=path-addr "dir1|dir2|dir3" gforth ``path=''
Here's an example of creating an empty search path:
create mypath 500 path-allot \ maximum length 500 chars (is checked)