read-line / princ problems 
Author Message
 read-line / princ problems

Hello all,


(defun get-name ()
  (let ((f nil) (l nil))
       (setq f (get-firstname))
       (setq l (get-lastname))
       (terpri)
       (princ "You entered:   ")
       (princ f)
       (princ " ")
       (princ l)
       (terpri)
       (cons f (list l))
  )
)

(defun get-firstname ()
  (princ "Enter first name:")
  (read-line)
)

(defun get-lastname ()
  (princ "Enter last name:")
  (read-line)
)

Nothig too complicated here (I hope), but when I test it I get the following
results:

CL-USER 26 : 2 > (get-name)
Enter first name:z
Enter last name:a

You entered:   z
("z" "")

CL-USER 27 : 2 > (get-name)
Enter first name:asdf
Enter last name:z

You entered:   asdf z
("asdf" "z")

CL-USER 28 : 2 > (get-name)
Enter first name:z
Enter last name:asdf

You entered:   z df
("z" "df")

CL-USER 29 : 2 > (get-name)
Enter first name:zxcv
Enter last name:asdf

You entered:   zxcv
("zxcv" "")

So, sometimes it works (as in the case for CL-USER 27) but ususally is
screws up.  It seems to always get the first name correct, but not the last.

Can anyone explain the odd behavior?

Thanks,
Pat Summers



Sat, 06 Apr 2002 03:00:00 GMT  
 read-line / princ problems

Quote:

> So, sometimes it works (as in the case for CL-USER 27) but ususally is
> screws up.  It seems to always get the first name correct, but not the last.

> Can anyone explain the odd behavior?

Your code, though not pretty, works for me with both Lispworks 4.1.17 and
ACL 5.0 Lite. And I don't see any reason why it shouldn't work.
Maybe there's something weird going on with your input stream?
Or are you working with a non-Common Lisp?


Mon, 08 Apr 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Problems with read-line

2. EXPECT: problem with reading lines for a file

3. problems reading out lines of a text-file

4. reading a line and executing a command on that line

5. how to read text files line by line?

6. reading file line by line

7. new question in how can i read data from file line by line

8. reading line by line

9. Reading line-by-line on a socket

10. line-by-line file read

11. Help: how to read line by line...

12. Read a text file line by line

 

 
Powered by phpBB® Forum Software