the following works fine:
[code](set 'out-buff "Now is the time to try men's souls")
(write-file "soulTest1.txt" out-buff) [/code]
but this doesn't:
[code](set 'out-buff "Now is the time to try men's souls")
(set 'out-file-handle (open "soulTest2.txt" "write"))
(write-file out-file-handle out-buff) [/code]
What's going on here? Many thanks.
vexing problem or bug?
-
- Posts: 2038
- Joined: Tue Nov 29, 2005 8:28 pm
- Location: latiitude 50N longitude 3W
- Contact:
I think out-file-handle is in fact an integer:
but write-file wants a string...
Code: Select all
(integer? out-file-handle)
;-> true
Yes, (write-file <str-file-name> <str-content>) is for writing an entire file in one shot.
Use (write-buffer <int-handle> <str-content>) if you want to write to a file handle, which also must be closed after writing.
Most of the time write-file does the job much easier in one statement. Use write-buffer only for bigger files, or when writing to a string buffer for fast destructive string appending (see manual).
Lutz
Use (write-buffer <int-handle> <str-content>) if you want to write to a file handle, which also must be closed after writing.
Code: Select all
(set 'out-buff "Now is the time to try men's souls")
(set 'out-file-handle (open "soulTest2.txt" "write"))
(write-buffer out-file-handle out-buff)
(close out-file-handle)
Lutz