Announcement

Collapse
No announcement yet.

Ascii Windows ANSI vs DOS File type question

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • #21
    I think it is proper to say that (Power)Basic Line Input # function
    is reading the line up to, but not including first CR (Chr$(13))
    That is, it detects CR or CRLF not LF alone....
    CR+CR+LF would be trated as TWO lines


    ------------------
    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se

    Fred
    mailto:[email protected][email protected]</A>
    http://www.oxenby.se

    Comment


    • #22
      Eric,
      Yes Im sure that each file with EITHER have lines of 80chars
      OR lines of 81chars. No file will ever have both


      Fred,
      thx for that I will examine it closely

      ------------------
      Kind Regards
      Mike

      Comment


      • #23
        ..I think it is slow because each time I ask for the next occurance
        of the CHR$(10) using PARSE$, it has to go thru the entire string "BinaryFile"
        counting up occurances of CHR$(10) untill it gets to BinLineNum.
        ....
        So I think I need to revert to plan B.. read a line at a time
        How about plan C?
        Code:
        x$ = EXTRACT$([start, ]MainString, [ANY] MatchString
        Or plan D?
        Code:
        REGEXPR mask$ IN main$ [AT start&] TO posvar&, lenvar&
        (BTW, there's a REGEXPR replacement for LINE INPUT in the Source Code forum)

        MCM

        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #24
          Mike
          1
          A UDT is a user defined type.
          This would also have the speed advantage that you can define sections of the line ready for processing rather than using Mid$ ie
          Code:
          Type Data80Col
            FirstPart as string * 41
            RawDate as string * 6
            RawTime as string * 4
            'etc
            LF as string * 1
          End Type
          Dim Inrec as Data80Col
          Open "File" for random as #1 Len = Len(Inrec)
          For x& = 1 to Lof(1) step len(Inrec)
            Get #1, x&, Inrec
           'etc
          Next
          Remember to put room for the LF in the type
          By the way the example you gave is only 70 characters

          2
          Unless you want to write the file to an editor rather than process it' then the LF or CRLF is only a means of breaking up the records, so you dont care which it is, so long as you can identify it. This means that reading the whole file in one go (as I showed in my second example) and then breaking it into seperate records is the simplest and probably faster than attempting any conversion and doesnt care about line length. I regularly use this method to process UNIX files.


          ------------------

          Comment


          • #25
            Ih ave some proprietary Unix->Pc code, forgot who sent it to me (KF Hon?)..

            So I don't want to give away his work, but apparantly it worked well, your results may be faster however....

            Didn't play at all with this, just remembered having it..

            Code:
             Open IN1 For Binary As #1
             Open IN2 For Output As #2
             TempStr$ = ""
            While Not Eof(1)
             Get$ 1, 1, Char$
             If CHAR$<> Chr$(10) Then
                 TempStr$ = TempStr$ + Char$
             Else
                 Print #2, TEMPSTR$
                 TEMPSTR$=""
             End If
            Wend
            ------------------
            Scott
            Scott Turchin
            MCSE, MCP+I
            http://www.tngbbs.com
            ----------------------
            True Karate-do is this: that in daily life, one's mind and body be trained and developed in a spirit of humility; and that in critical times, one be devoted utterly to the cause of justice. -Gichin Funakoshi

            Comment

            Working...
            X