Results 1 to 5 of 5

Thread: Trouble with text File

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Location
    Athens, Greece
    Posts
    27

    Parse Text File to an Array

    Hi Everybody,

    I need your help. I have a text file which i include in the message. As you can see this is a log file, now the problem is that i want to seperate each test that start with @Start......@ ..... and ends with @End.....@ and after that i want to put each value on differents arrays.

    example.

    Start State Reaction End State Time Stamp
    1 1 3 0,030
    3 3 5 0,060

    etc.

    I have write a code looks like this (this is a sample of the code):


    Code:
    Public Sub Simple_Reaction_Time_Shape()
    Dim ac As Single
    Dim bc, dc As Single
    Dim i As Integer
    Open App.Path & "\" & "SimpleReactionTimeShapeTemp.ini" For Output As #2
        Do While Not EOF(1) And Left(Fline, 26) <> "@Simple_Reaction_Time_End@"
            bc = ac
            
            Line Input #1, Fline
            If Left(Fline, 13) = "Start State: " Then
                Start_State = Val(Right(Fline, Len(Fline) - 13))
            Line Input #1, Fline
                Event_State = Val(Right(Fline, Len(Fline) - 10))
            Line Input #1, Fline
                End_State = Val(Right(Fline, Len(Fline) - 11))
            Line Input #1, Fline
                ac = Val(Comma2Dot(Right(Fline, Len(Fline) - 11)))
            
        End If
        
      '      Add ac, r, es, ss   Format(A(9), "#0.###")
            dc = ac - bc
            dc = Format(dc, "#0.###")
            i = i + 1
            Debug.Print i, Cand_Number, Left_Hand, Right_Hand, Date_Exam, Test_Name, Start_State, Event_State, End_State, ac, dc
            
            Print #2, i & "." & Cand_Number & "." & Left_Hand & "." & Right_Hand & "." & Date_Exam & "." & Test_Name _
            & "." & Start_State & "." & Event_State & "." & End_State & "." & ac & "." & dc
        Loop
    Close #2
    End Sub

    but i have a lot of problem because each test is difference.
    Thanks in advance for any help.
    Attached Files Attached Files

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Trouble with text File

    Give me an example of the string.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Location
    Athens, Greece
    Posts
    27

    Re: Trouble with text File

    This is the code:

    Code:
    Private Sub cal_but_Click()
    
    Dim sText, pos1, pos2
    Dim I
    Dim CompareString1, CompareString2 As String
    Dim Number As Long
    
    FFile = FreeFile
    
    If List1.ListIndex <> -1 Then
        Text38.Text = List1
       
       
        Open Dir1.Path & "\" & List1.Text & ".txt" For Input As #FFile
    
             sText = Input(LOF(1), #FFile)
        Close #FFile
    and this is the stiring:

    @Simple Reaction Time@
    0,02
    Start State: 1
    Reaction: 0
    End State: 1
    Time Stamp:0,017
    Start State: 1
    Reaction: 1
    End State: 3
    Time Stamp:50,892
    .
    .
    @Simple_Reaction_Time_End@
    @Simple Reaction TIME Sound@
    Start State: 1
    Reaction: 0
    End State: 1
    Time Stamp:0,017
    Start State: 1
    Reaction: 1
    End State: 3
    Time Stamp:50,892
    .
    .
    .
    @Simple_Reaction_Sound_End@
    @Reaction_Time_Position_Start@
    Start State: 1
    Reaction: 0
    End State: 1
    Time Stamp:0,017
    Start State: 1
    Reaction: 1
    End State: 3
    Time Stamp:50,892
    .
    .
    @Reaction_Time_Position_End@

    etc.

    i need to take the data from the string

    Thanx

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Trouble with text File

    When you said string, I thought of a single line of text.

    What do you need to take from the string?

    Once you have it, what do you need to do with it?

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2007
    Location
    Athens, Greece
    Posts
    27

    Re: Trouble with text File

    i need to take the information from the string between the marks @Start...@ and @End....@

    and then add it to an array.

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