From: proton on 29 Jun 2010 05:54 Hi all, I am trying to read a text file using read-line within a loop. In the file there is a line with one single word followed by a colon, "follows:". When the program reaches that line, instead of processing it as the rest, it takes it as the definition of a package. Then, the next line it returns an error "Unknown follows: package". Is there a way to prevent this and treat the line with the colon as a normal string? I am using CLISP 2.47 on Win32. Thanks for your help.
From: Tamas K Papp on 29 Jun 2010 07:11 On Tue, 29 Jun 2010 02:54:13 -0700, proton wrote: > Hi all, > > I am trying to read a text file using read-line within a loop. In the > file there is a line with one single word followed by a colon, > "follows:". > When the program reaches that line, instead of processing it as the > rest, it takes it as the definition of a package. Then, the next line it > returns an error "Unknown follows: package". If you are using just read-line in a loop, then I find that behavior surprising, as readline does no parsing (other than detecting newlines). > Is there a way to prevent this and treat the line with the colon as a > normal string? Maybe you should post the code so we could see what's going on. Tamas
From: Teemu Likonen on 29 Jun 2010 07:24 * 2010-06-29 02:54 (-0700), proton wrote: > I am trying to read a text file using read-line within a loop. > In the file there is a line with one single word followed by a colon, > "follows:". > When the program reaches that line, instead of processing it as the > rest, it takes it as the definition of a package. Then, the next line > it returns an error "Unknown follows: package". > > Is there a way to prevent this and treat the line with the colon as a > normal string? That shouldn't happen in the first place. (with-input-from-string (s (format nil "first line~%follows:~%third line")) (values (read-line s) (read-line s) (read-line s))) => "first line", "follows:", "third line" I think you are actually using something like READ-FROM-STRING which uses the Lisp reader to parse the strings.
From: proton on 29 Jun 2010 08:47 My apologies, I forgot to mention that after a read-line, I do a read- from-string. That´s where the error occurs. On Jun 29, 1:11 pm, Tamas K Papp <tkp...(a)gmail.com> wrote: > On Tue, 29 Jun 2010 02:54:13 -0700, proton wrote: > > Hi all, > > > I am trying to read a text file using read-line within a loop. In the > > file there is a line with one single word followed by a colon, > > "follows:". > > When the program reaches that line, instead of processing it as the > > rest, it takes it as the definition of a package. Then, the next line it > > returns an error "Unknown follows: package". > > If you are using just read-line in a loop, then I find that behavior > surprising, as readline does no parsing (other than detecting newlines). > > > Is there a way to prevent this and treat the line with the colon as a > > normal string? > > Maybe you should post the code so we could see what's going on. > > Tamas
From: Pascal J. Bourguignon on 29 Jun 2010 10:20 proton <leosarasua(a)gmail.com> writes: > On Jun 29, 1:11�pm, Tamas K Papp <tkp...(a)gmail.com> wrote: >> On Tue, 29 Jun 2010 02:54:13 -0700, proton wrote: >> > Hi all, >> >> > I am trying to read a text file using read-line within a loop. In the >> > file there is a line with one single word followed by a colon, >> > "follows:". >> > When the program reaches that line, instead of processing it as the >> > rest, it takes it as the definition of a package. Then, the next line it >> > returns an error "Unknown follows: package". >> >> If you are using just read-line in a loop, then I find that behavior >> surprising, as readline does no parsing (other than detecting newlines). >> >> > Is there a way to prevent this and treat the line with the colon as a >> > normal string? >> >> Maybe you should post the code so we could see what's going on. > > My apologies, I forgot to mention that after a read-line, I do a read- > from-string. That�s where the error occurs. What would you expect then? Why would you want to use READ-FROM-STRING, if your string doesn't contain a lisp form? -- A: Because it messes up the order in which people normally read text. Q: Why is top-posting such a bad thing? A: Top-posting. Q: What is the most annoying thing on usenet and in e-mail? ----------> http://www.netmeister.org/news/learn2quote.html <----------- ---> http://homepage.ntlworld.com/g.mccaughan/g/remarks/uquote.html <--- __Pascal Bourguignon__ http://www.informatimago.com/
|
Next
|
Last
Pages: 1 2 Prev: Third World War is Coming - Who is Webster Tarpley ? Next: Algebra Rizing |