Talk About Network



Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Eiffel > Re: PLAIN_TEXT_...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 5 Topic 896 of 913
Post > Topic >>

Re: PLAIN_TEXT_FILE

by Jean RUPPERT <ruppertj@[EMAIL PROTECTED] > Nov 3, 2007 at 07:08 PM

Hello Roman,

     I only have smarteiffel, and I cannot
testy your code, so I don't know what is
wrong with it. Maybe reading and writing
at the same time to a file causes some problems.
Maybe you read again the line you just have written
I would try this out, even though it is not very
elegant. If it does not help you please tell me

                   Yours

                           Jean

class
      APPLICATION
  create
      make
  feature -- Initialization
      make is
              -- Run application.
          local
              input_file: PLAIN_TEXT_FILE
              output_file: PLAIN_TEXT_FILE
              text_line: STRING
          do
              create input_file.make_open_read ("kunden.tab")
              create output_file.make_open_write ("kunden_neu.tab")
              if input_file.exists then
                  if input_file.readable and output_file.writable then
                      from
                          input_file.start
                      until
                          input_file.end_of_file
                      loop
                          input_file.read_line
                          text_line := input_file.last_string.substring 

                                              (7, file.last_string.count)
                          output_file.put_string (text_line)
                          input_file.next_line
                      end
                  end
                  output_file.close
                  input_file.close
              end
          end
  end -- class APPLICATION


Roman Töngi a écrit :
> I want to change a file consisting of customer records.
> Every line is finished by a return; so I think the file
> should be formated properly.
> 
> I read every line one after the other, rewriting the lines
> without the first seven characters.
> 
> The first line is read correctly, but remains unchanged.
> Furthermore, file.next_line does not move to the next line but
> to a arbitrary position.
> 
> What is wrong with the code? Thanks for any help.
> 
> 
> 
> class
>     APPLICATION
> create
>     make
> feature -- Initialization
>     make is
>             -- Run application.
>         local
>             file: PLAIN_TEXT_FILE
>             text_line: STRING
>         do
>             create file.make_open_read_write ("kunden.tab")
>             if file.exists then
>                 if file.readable and file.writable then
>                     from
>                         file.start
>                     until
>                         file.end_of_file
>                     loop
>                         file.read_line
>                         text_line := file.last_string.substring (7, 
> file.last_string.count)
>                         file.put_string (text_line)
>                         file.next_line
>                     end
>                 end
>                 file.close
>             end
>         end
> end -- class APPLICATION




 5 Posts in Topic:
PLAIN_TEXT_FILE
=?ISO-8859-1?Q?Roman_T=F6  2007-11-03 15:21:34 
Re: PLAIN_TEXT_FILE
Jean RUPPERT <ruppertj  2007-11-03 19:08:08 
Re: PLAIN_TEXT_FILE
=?ISO-8859-1?Q?Roman_T=F6  2007-11-03 20:37:09 
Re: PLAIN_TEXT_FILE
Ulrich Windl <Ulrich.W  2007-11-07 09:35:48 
Re: PLAIN_TEXT_FILE
"Bernd Schoeller&quo  2007-11-07 10:43:10 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Thu May 15 22:05:45 CDT 2008.