Hi
I found a function which shows the current working directory on
http://www.newlisp.org/index.cgi?page=Code_Snippets
which is very handy
Is there a function which is similar to the Tcl glob function?
http://tmml.sourceforge.net/doc/tcl/glob.html
I would like to say
(glob "*.txt")
and get back a list of all file names in the current working directory matching the pattern.
Perhaps somebody already has implemented something like this?
Thanks for the answer in advance.
HJH
Use 'filter' to filter out the files you want
> (filter (fn (f) (ends-with f ".c")) (directory))
("newlisp.c" "nl-count.c" "nl-debug.c" "nl-filesys.c" "nl-import.c"
"nl-list.c" "nl-liststr.c" "nl-math.c" "nl-matrix.c" "nl-sock.c"
"nl-string.c" "nl-symbol.c" "nl-utf8.c" "nl-web.c" "nl-xml.c" "osx-dlfcn.c"
"pcre-chartables.c" "pcre.c" "sql.c" "tru64.c" "types.c" "unix-lib.c"
"win32-util.c" "win32dll.c")
or on UNIX, this gives you the same:
(exec "ls *.c")
I don't have a Windows machine close, but I think:
(exec "dir /b")
would work, or may be you would have to call the shell:
(exec "cmd /c dir /b")
Lutz