Hi Thorsten,

> Is there a way to make 'out' write directories too?

No, 'out' just creates or opens a file for writing.

> Or do I have to use something like
> ,--------------------------
> | (call 'mkdir "/new/dir/")
> `--------------------------

Yes. But this works only if "/new/" already exists. If "/new/" is also
missing, you can create the complete path with

      (call 'mkdir "-p" "/new/dir/")

(BTW, do you really want to write to the root directory "/"?)

> ,-----------------------
> | (call 'cd "/new/dir/")
> `-----------------------
> then 
> ,------------------------------------------------
> | (out "newfile" (in "a" (echo)) (in "b" (echo))) |
> `------------------------------------------------

No. 'cd' is a shell builtin, and cannot be used wit 'call'.

There are two lisp functions for that, 'cd' and 'chdir'

   (cd "/new/dir/")


   (chdir "/new/dir/" .. <body> ..)

The difference is that 'chdir' executes the body and then restores the
original working directory (also if an exception (throw) occurs within
the body).

   (chdir "/new/dir/" (out "newfile" ..))

But in general I would be careful with 'cd' and 'chdir', as it modifies
the working directory of the whole process. For example, "a" and "b"
above will not be found (as the directory is new), and you must use
"../../a" or something like that.

Better is usually to call

   (let Dir "/new/dir/"
      (call 'mkdir "-p" Dir)
      (out (pack Dir "newfile") (in "a" ...)) )

- Alex
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to