Results 1 to 6 of 6

Thread: Line Input

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    247
    Line Input gets a line in a text file. Is there something like that against string buffer. Example, Kedaman showed me how to get an entire text file into a string. I want to know if there is a way to go through each carriage return or do I have to program a function that is similar to Line Input.
    Mako Shark
    Great White

  2. #2
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    What do you mean by going through each carriage return? In fact Line Input gets a line at a time and each line ends in a carriage return in the file, or, the carriage return is the separator between lines in a file.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Posts
    247

    Thanks for your reply

    That is what I want to do. Something similar to Line Input, but for a buffer string that has used the GET method.
    Mako Shark
    Great White

  4. #4
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    Sure!
    If you have VB6:
    Use Split to add each line to an array.

    You have VB5? Here's the code for a split function (dunno who wrote it, got the code from kedaman)

    Code:
    Public Function Split(ByVal sIn As String, Optional sDelim As String, Optional nLimit As Long = -1, Optional bCompare As VbCompareMethod = vbBinaryCompare) As Variant
        Dim sRead As String, sOut() As String, nC As Integer
        If sDelim = "" Then
            Split = sIn
        End If
        sRead = ReadUntil(sIn, sDelim, bCompare)
        Do
            ReDim Preserve sOut(nC)
            sOut(nC) = sRead
            nC = nC + 1
            If nLimit <> -1 And nC >= nLimit Then Exit Do
            sRead = ReadUntil(sIn, sDelim)
        Loop While sRead <> ""
        ReDim Preserve sOut(nC)
        sOut(nC) = sIn
        Split = sOut
    End Function
    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Hey don't use that one, it's the slower one, Iain made a much faster one, but, if you are using Vb6 then use the split function implemented there, it's even faster

    Code:
    Private Sub Mysplit(Source, searchs As String, ByRef Arr() As String)
        Dim pos As Long, pos2 As Long, x As Long
        pos = 0
        If Right(Source, Len(searchs)) = searchs Then
            Source = Mid$(Source, 1, Len(Source) - Len(searchs))
        End If
        Do
            pos = InStr(pos + 1, Source, searchs, vbTextCompare)
            If pos = 0 Then Exit Do
            ReDim Preserve Arr(x)
            Arr(x) = Mid(Source, pos + 1, pos + Len(searchs) - 2)
            x = x + 1
        Loop
    End Sub
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Jop
    Your's was written (Originally Posted) by Aaron Young.
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width