1

I'm working my way through Computer Science Logo Style using UCB Logo 6.0 on Win10

One of the examples is the extract procedure, on this page: https://people.eecs.berkeley.edu/~bh/v2ch1/files.html

My problem is that it will only read one line from the file when I think it's supposed to read everything until the end of the file. I made the sample file (a plain text address book) using Notepad.exe with 2 entries separated by a hard return (the ENTER) key.

Here's the procedure and a sample of using it from the book:

to extract :word :file
openread :file
setread :file
extract1 :word
setread []
close :file
end

to extract1 :word
local "line
if eofp [stop]
make "line readlist
if memberp :word :line [print :line]
extract1 :word
end

To use it: ? extract "brian "phonelist (with phonelist being the file name)

And the result should be:

Brian Harvey 555-2368
Brian Silverman 555-5274

My sample file had the 2 Brian lines but only the first one is retrieved. Any ideas what's going on? - Thanks

OutThere
  • 467
  • 2
  • 8
  • 19

0 Answers0