Sign in to follow this  
Followers 0
d0n

using array in if statements?

3 posts in this topic

I am not sure why this doesn't work, when i run it the first msgbox shows me "Jon Jon" which means its a match but for some reason the IF statement wont pick it up.

Here is the code

$Log = @ScriptDir&"\Logger.ini"

Dim $sStr = FileRead(@scriptdir & "\test.txt")

Dim $sPatt = '(?i)\[[^]]*\]\s*(.*?)(?:hit|punche?|slashe?)s?.*?for\s*(\d+)'
Dim $aLines = StringSplit($sStr, @CRLF, 1)

Global $P1_Total = 0

For $i = 1 To $aLines[0]
    Local $aMatch = StringRegExp($aLines[$i], $sPatt, 1)
    If UBound($aMatch) = 2 Then
        $a = IniReadSection($Log, "Name")
        For $size=1 To $a[0][0]
            MsgBox("","",$a[$size][0]&" "&$aMatch[0])
            If $a[$size][0] = $aMatch[0] Then
                MsgBox("","","Match")
            EndIf
        Next
    EndIf
Next

Here is the FileRead(@scriptdir & "\test.txt"

[9:56:47 PM Jun 20 2009] Jon slash Dragon for 1252 points of damage.
[9:56:47 PM Jun 20 2009] Jon slash Dragon for 3252 points of damage.
[9:56:47 PM Jun 20 2009] jon2 slash Dragon for 21 points of damage.
[9:56:47 PM Jun 20 2009] jon2 slash Dragon for 54 points of damage.

Here is the ini (@ScriptDir&"\Logger.ini")

[Name]
Jon=3252
jon2=52

Share this post


Link to post
Share on other sites



I think it's because in the $aMatch[0] has extra space, no?

Try change MsgBox("","",$a[$size][0]&" "&$aMatch[0]) to

MsgBox("","",$a[$size][0]&"' "&$aMatch[0]&"'")

Share this post


Link to post
Share on other sites

oh, yea that was the problem, thanks for the help

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0