EMA-XPS Online
WITH-OPEN-FILE
WITH-OPEN-FILE
==============
syntax: (with-open-file
; Common Lisp: This function realises
in- and output!
(<stream-var> <filename>
[{<options> ...}])
[{<declaration> ...}]
[{<form> ...}])
(with-open-input-file
; Babylon Lisp
(<stream-var> <filename>)
{<form> ...})
(with-open-output-file
; Babylon Lisp
(<stream-var> <filename>
[<if-exists-option>])
{<form> ...})
This function opens a file with the name <filename>
for reading or writing. If the file can not be opened,
then NIL will be returned.
examples: >(with-open-file (f "test.temp"
:direction :output)
(print '(1 2 3 4 5) f)
(format f "~%abc"))
NIL
>(with-open-file (f "test.temp"
:direction :input)
(list (read f)
(read-line f
'has-to-be-a-line)
(read f 'end)
(read-line f 'end2)))
((1 2 3 4 5) " " ABC END2)
In this example: A file with the name
"test.temp" is made and
(1 2 3 4 5)
abc
is written into this file!
EMA-XPS Online