LispWorks multiplication-table.list example: No errors, Where is the file it is writing?
I am trying to insert my code into the LispWorks example. My code is
supposed to write to a log file, "log.txt".
I tried my code in the listener. I get the file "log.txt" where I
expect it. However, when I run the example, I don't find any file. I
don't get any errors.
My code is:
========== start of code ==========
;;; This is the "computation" that this server is doing.
(defun format-multiplication-table-line (stream line integer)
(print-at-server-too
stream
;; The following is the original line of the example file:
;; (format stream "~D x ~D = ~D" line integer (* line integer)) )
)
;; I modified to return a string which is passed to function
print-at-server-too
(format nil "~D x ~D = ~D~%" line integer (* line integer)) ) )
(defun print-at-server-too (stream str-to-print)
;; The following line does what used to be done
;; in the calling function
(format stream str-to-print)
;; This calls my function to write the same thing to
;; a file on the server
(print-at-server-too-1 str-to-print)
;; This returns the same string passed into this function
str-to-print)
(defun print-at-server-too-1 (a-str)
;;; This is supposed to open a file, append the string
;;; then close the file. Don't get any errors. But cannot
;;; find the file written. Where is it? Not in (get-working-directory).
;;; Is it written anywhere?
(with-open-file (out-log "log.txt" :direction :output
:if-exists :append :if-does-not-exist :create)
(write-line a-str out-log)) )
========== end of code ==========
I don't know whether this will work because I am new, but I will attach the
2
example files, "multiplication-table.lisp" (which I modified) and
"driver.lisp".
Maybe there is something about multiple threads, which I think this example
uses. But I don't think there should be. I would think all threads should be
able to write to a file, just not at the same time to the same file.
I also appreciate any tips in how to use this forum. Since Gmane is not
working, I never was able to see anything that was posted before. And I
don't know whether this is how it is supposed to be or not.
My question is: Is "log.txt" getting written anywhere?
Ron Lewis