Parsing PGN files

My idea was if a line of data has a "." in it but no "[" or "]", then its a line of moves. However, my problem is with it spread over several lines and concatenating them
 
Is this syntax correct for checking if both a "." exists and a "[" doesn't exist in the string?

Code:
If (InStr(var(i), ".") = True) And (InStr(var(i), "[") = False) Then
 
Instr returns an Integer value of the position of the first character of the string if found. Have a look in the Help Files for a much detailed explanation.

With regards field names, like I mentioned in this post:
When you're checking for field names, use the first item in the array, myFieldsArray(0). Whatever is in there would be your field name.
Then you strip off the left square bracket using Replace(), or read it off using Right() or Mid() and Len().

Did you see Dave's last editted post?
 
I'm very nearly there. :) Only problem I am getting is that it does not get the very last line of moves, but only on the very last game. It gets the moves for the earlier games ok.

Any idea why?


Code:
    'Cycle through lines
    For i = 0 To UBound(var)
        'Check if Move line
        If (Len(var(i) > 0)) And (InStr(var(i), "[") = 0) Then
            'Cycle through Move lines only
            tmpMove = ""
            x = 0
            Do
                tmpMove = tmpMove & var(i + x)
                x = x + 1
            Loop While (Len(var(i + x) > 0)) And (InStr(var(i + x), "[") = 0) And UBound(var) > x + i
            i = i + x
            MsgBox tmpMove
            Debug.Print tmpMove
        Else
            Debug.Print var(i)
        End If
    Next
 
All sorted? Goodie! If you don't want to use Exit Do just move the While condition to the top, i.e.

Code:
Do While....

Loop
 

Users who are viewing this thread

Back
Top Bottom