newlines?

Q&A's, tips, howto's
Locked
methodic
Posts: 58
Joined: Tue May 10, 2005 5:04 am

newlines?

Post by methodic »

I am reading a bunch of data from STDIN, saving each line in a variable, then I am concatinating the newest line with the older data, but it seems newlisp is stripping out the newline chars.

example:
(set 'full "")

(while (set 'n (read-line (device)))
(set 'full (string body n)))

if i do a (print full), I get everything, minus the newlines.

Am i missing something?

methodic
Posts: 58
Joined: Tue May 10, 2005 5:04 am

Post by methodic »

nevermind, i figured out that read-line chops off the newline, so Im simply doing this:

(set 'full (string body n "\n")))

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

But your program isn't appending but setting the variable 'full' each time. Here is a method to do a quick string append:

Code: Select all

(set 'full "")

(while (set 'n (read-line (device)))
    (write-buffer full (string body n))) 
Now 'full' will get appended each time

Lutz

ps: welcome to the group Methodic

Locked