Lisp HUG Maillist Archive

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


Re: LispWorks multiplication-table.list example: No errors, Where is the file it is writing?

Why not give a full pathname, instead of just ”log.txt”? That way you could control yourself where the file ends up!

Erik



> 29 mars 2017 kl. 00:33 skrev rlewis-4d@indinfer.com:
> 
> 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
> 
> <driver.lisp><multiplication-table.lisp>


_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Re: LispWorks multiplication-table.list example: No errors, Where is the file it is writing?

> Am 29.03.2017 um 00:33 schrieb <rlewis-4d@indinfer.com> <rlewis-4d@indinfer.com>:
> 
> I am trying to insert my code into the LispWorks example. My code is
> supposed to write to a log file, "log.txt”.

“log.txt” is not a complete pathname. It only specifies the name and the type components of a pathname.
In portable Common Lisp the missing components (directory, …) are coming from the value of *DEFAULT-PATHNAME-DEFAULTS* .

If there is not a more specific pathname in there, then it might lead to your file ending up in the root directory - on Unix-like machines.




_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Re: LispWorks multiplication-table.list example: No errors, Where is the file it is writing?

From what I have found about LW, it starts in the root directory by default ‘/‘, so I would check there to see if it’s been written.  You can change directories using change-directory: http://www.lispworks.com/documentation/lw445/LWRM/html/lwref-172.htm

—
Burton Samograd

On Mar 28, 2017, at 4:33 PM, <rlewis-4d@indinfer.com> <rlewis-4d@indinfer.com> wrote:

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

<driver.lisp><multiplication-table.lisp>

Updated at: 2020-12-10 08:31 UTC