Jump to content

checking a Variable error


Recommended Posts

If $aList[$n] is finished, it gives an error.
How do I need to provide control for this?

(22) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:
$ReadString = StringRegExp($aList[$n], '[a-zA-Z0-9_\\.-]+@[a-zA-Z0-9\-]+\.+[a-zA-Z0-9]{2,4}', 3)
$ReadString = StringRegExp(^ ERROR

#include <GUIConstantsEx.au3>
#include <String.au3>
#include <EditConstants.au3>
$Form1 = GUICreate("Form1", 418, 387, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 8, 72, 329, 169)
GUICtrlSetData($Edit1, "test1@mail.com" & @CRLF & "test2@mail.com")
$Input1 = GUICtrlCreateInput("", 8, 32, 329, 21)
$Button1 = GUICtrlCreateButton("Next Site", 16, 256, 75, 25)
GUISetState(@SW_SHOWNA)
$n = 0
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            $aList = StringSplit(GUICtrlRead($Edit1), @CRLF, $STR_ENTIRESPLIT)
            If GUICtrlRead($Button1) = "Next" Then
                $n += 1
                $ReadString = StringRegExp($aList[$n], '[a-zA-Z0-9_\\.-]+@[a-zA-Z0-9\-]+\.+[a-zA-Z0-9]{2,4}', 3)
                If IsArray($ReadString) Then GUICtrlSetData($Input1, $ReadString[0])
                GUICtrlSetData($Button1, "Pass")
            Else
                GUICtrlSetData($Button1, "Next")
            EndIf

    EndSwitch
WEnd

 

Link to comment
Share on other sites

#include <GUIConstantsEx.au3>
#include <String.au3>
#include <EditConstants.au3>
$Form1 = GUICreate("Form1", 418, 387, 192, 124)
$Edit1 = GUICtrlCreateEdit("", 8, 72, 329, 169)
GUICtrlSetData($Edit1, "test1@mail.com" & @CRLF & "test2@mail.com")
$Input1 = GUICtrlCreateInput("", 8, 32, 329, 21)
$Button1 = GUICtrlCreateButton("Next Site", 16, 256, 75, 25)
GUISetState(@SW_SHOWNA)
$n = 0
While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Button1
            $aList = StringSplit(GUICtrlRead($Edit1), @CRLF, $STR_ENTIRESPLIT)
            If GUICtrlRead($Button1) = "Next" Then
                $n += 1

                If $n > $aList[0] Then
                    GUICtrlSetData($Button1, "=P")
                    ContinueLoop
                EndIf

                $ReadString = StringRegExp($aList[$n], '[a-zA-Z0-9_\\.-]+@[a-zA-Z0-9\-]+\.+[a-zA-Z0-9]{2,4}', 3)
                If IsArray($ReadString) Then GUICtrlSetData($Input1, $ReadString[0])
                GUICtrlSetData($Button1, "Pass")
            Else
                GUICtrlSetData($Button1, "Next")
            EndIf

    EndSwitch
WEnd

 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

@argumentum Actually instance is seamless nice, thanks.

Actually, should GUICtrlSetData ($Button1, "Done") and disable the button
like this :)

Case $Button1
            $aList = StringSplit(GUICtrlRead($Edit1), @CRLF, $STR_ENTIRESPLIT)
            If GUICtrlRead($Button1) = "Next" Then
                $n += 1
                If $n > $aList[0] Then
                    GUICtrlSetData($Button1, "Done")
                    GUICtrlSetState($Button1, $GUI_DISABLE)
                    ContinueLoop
                EndIf

                $ReadString = StringRegExp($aList[$n], '[a-zA-Z0-9_\\.-]+@[a-zA-Z0-9\-]+\.+[a-zA-Z0-9]{2,4}', 3)
                If IsArray($ReadString) Then GUICtrlSetData($Input1, $ReadString[0])
                GUICtrlSetData($Button1, "Pass")
            Else
                GUICtrlSetData($Button1, "Next")
            EndIf

@Nine Thanks for trying to find out another example would be nice. :)

 

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...