/tutorial/io/read_line.e

http://github.com/tybor/Liberty · Specman e · 35 lines · 23 code · 5 blank · 7 comment · 1 complexity · de02cfa616e0a22d3945d6e9e032716f MD5 · raw file

  1. class READ_LINE
  2. -- This example show how to use read_line.
  3. -- The reading pattern is different from the one used with read_character.
  4. -- It HAS to be different.
  5. create {ANY}
  6. make
  7. feature {}
  8. make is
  9. local
  10. tfr: TEXT_FILE_READ
  11. do
  12. from
  13. create tfr.connect_to("read_line.e")
  14. until
  15. tfr.end_of_input
  16. loop
  17. tfr.read_line
  18. if tfr.end_of_input then
  19. -- The last line of the file does not end with a new
  20. -- line character. Remove this test if you don't care.
  21. std_output.put_string(tfr.last_string)
  22. else
  23. std_output.put_line(tfr.last_string)
  24. end
  25. end
  26. tfr.disconnect
  27. end
  28. -- NOTE: last_string always returns the same STRING object, it's up
  29. -- to you to make a copy if you need to keep the string value.
  30. end