Jump to content

looping array with something that returns as array?


d0n
 Share

Recommended Posts

I have something like this i want to put in a loop, however the return for the StringRegExp is also an array, how should i go at this?

$aMatch1A = StringRegExp($Lines[$a], $Skill_1A, 1)
$aMatch1B = StringRegExp($Lines[$a], $Skill_1B, 1)
$aMatch2A = StringRegExp($Lines[$a], $Skill_2A, 1)
$aMatch2B = StringRegExp($Lines[$a], $Skill_2B, 1)

Edit:

what i am trying to do is to make this code better, by looping those repetitive lines

For $a = $Start To $Lines[0]

    $aMatch1A = StringRegExp($Lines[$a], $BossMod_Skill_1A, 1)
    $aMatch1B = StringRegExp($Lines[$a], $BossMod_Skill_1B, 1)
    $aMatch3A = StringRegExp($Lines[$a], $BossMod_Skill_3A, 1)
    $aMatch3B = StringRegExp($Lines[$a], $BossMod_Skill_3B, 1)

    Select
        Case $aMatch1A <> 0 AND $aMatch1A[1] = $target
            GUICtrlSetData($BossMod_Editbox1, $aMatch1A[0]&" - 1 Start"&@CRLF,GUICtrlRead($BossMod_Editbox1))
        Case $aMatch1B <> 0 AND $aMatch1B[1] = $target
            GUICtrlSetData($BossMod_Editbox1, $aMatch1B[0]&" - 1 Over"&@CRLF,GUICtrlRead($BossMod_Editbox1))
        Case $aMatch3A <> 0 AND $aMatch3A[1] = $target
            GUICtrlSetData($BossMod_Editbox1, $aMatch3A[0]&" - 2 Start"&@CRLF,GUICtrlRead($BossMod_Editbox1))
        Case $aMatch3B <> 0 AND $aMatch3B[1] = $target
            GUICtrlSetData($BossMod_Editbox1, $aMatch3B[0]&" - 2 Over"&@CRLF,GUICtrlRead($BossMod_Editbox1))
    EndSelect
Next
Edited by d0n
Link to comment
Share on other sites

Maybe something like this (untested)

Dim $aAllMatches[4]

$aAllMatches[0] = StringRegExp($Lines[$a], $Skill_1A, 1)
$aAllMatches[1] = StringRegExp($Lines[$a], $Skill_1B, 1)
$aAllMatches[2] = StringRegExp($Lines[$a], $Skill_2A, 1)
$aAllMatches[3] = StringRegExp($Lines[$a], $Skill_2B, 1)

For $i = 1 To UBound($aAllMatches) - 1
    $tarray = $aAllMatches[$i]
    If IsArray($tarray) Then
        MsgBox (0, "", $tarray[0])
        For $x = 1 To $tarray[0]
            If $tarray[$x] = $target Then
                ConsoleWrite("[" & $i & "] is what we want." & @CRLF)
            Else
                ConsoleWrite("[" & $i & "] is not what we want. (" & $tarray[$x] & ")" & @CRLF)
            EndIf
        Next
    Else
        ConsoleWrite("[" & $i & "] is not an array." & @CRLF)
    EndIf
Next
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...