Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

WindowXP text file terminus

Developers
2007-04-25
2012-08-14
  • Windows XP put a character at the end of my .txt files that looks like a small square (some kind of carriage control, I bet). Is there a way to not put it there? Files were made using IBM OS/2.

    --Gary

     
    • Lee--

      Got it. thanks.

      --Gary

       
    • Files can be created numerous ways using OS/2. Where they create with Rexx or an editor?

       
    • Make that "were" not "where" - been a long day

       
    • They were created by a report writer for dBase and I read them with ooRexx. In OS/2 the character is either not there or not a problem for OS/2 Rexx. I can delete it with notepad, but its a lot of files. I'm working on a way for 00Rexx to use this to know when it has reached the end of the file, but that approach may mean my ooRexx application will not be compatable with years of historic files. As I'm self-educated in Rexx, I never figured out how to read the (indexed)dBase files directly.

       
    • Gary,
      It's probably an EOF (end of file) marker. Could you send me one of these files - if the data is sensitive, remove the sensitive part and forward to me. Don't know how you're reading the file with ooRexx, but if you're using "linein", I can so you a MUCH faster method that is only about 3 lines of code and at the same time strip that problemson character from the end of the file.

      I'm going to start packing to day for the road trip to the RexxLA Symposium, but should have a little time on Friday to offer some assistance.

      You know how to reach me :-)

      Lee

       
    • Lee-

      Yes, I am using Linein. I emailed a sample file to you.

      --Gary

       
    • Lee Peedin
      Lee Peedin
      2007-05-04

      In case anyone else was following this thread, I'm posting the resolution here:

      With a sample of the data it was determined that the offending character was a EOF marker. It was also determined that the EOF was preceded by a CR/LF and that the true length of the character was 1.

      With that information in hand the following solution was offered:

      / gary_read.rex /

      -- Define the path and file name to be read
      infile = '.\qtr.064'

      -- Create a stream object
      istream = .stream~new(infile)

      -- Read in the stream object
      -- Read the entire stream in one pass - very fast
      -- | Where to start reading, default is the first character
      -- | | What to read in (the stream object we created above)
      -- | | | How many characters to read in
      -- | | | | Leave out the EOF character we don't want
      -- | | | | | Make an ooRexx array (CR/LF is the default delimiter)
      -- | | | | | |
      iarray = istream~charin( , istream~chars-1)~makearray

      -- We're done with the file now, so close the stream
      istream~close

      -- All the data we want from the file is now in an ooRexx array (iarray)
      do i = 1 to iarray~items
      -- Each line can be dealt with here using substr or better yet "positional" parse
      say iarray[i]
      end

       
    • Lee-

      Doesn't "chars-1" mean read all but the last character? If so, what if the file doesn't have the EOF character, like the ones I removed it from before I had your solution?

      ????
      SeeWhatItIs = call charin infile(istream~chars,1) (syntax???)
      if SeeWhatItIs = end of file character (However you make the character)
      then readchars = istream~chars-1
      else readchars = istream~chars

      iarray = istream~charin( , readchars)~makearray

      ????

       
    • Lee Peedin
      Lee Peedin
      2007-06-07

      Yes -1 says get all but the last character - in your situation where you may or may not have the character, I'd suggest doing this.

      iarray = istream~charin( , istream~chars)~makearray -- Note getting everything
      istream~close

      -- The following assumes that your actual data lines will be longer than 1 character
      if iarray[iarray~items]~length = 1 then
      iarray~remove(iarray~items)

      -- All the data we want from the file is now in an ooRexx array (iarray)
      do i = 1 to iarray~items
      -- Each line can be dealt with here using substr or better yet "positional" parse
      say iarray[i]
      end