Jump to content
Sign in to follow this  
youtuber

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

 

Share this post


Link to post
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

 

Share this post


Link to post
Share on other sites

To be logical, should the StringSplit be outside the loop ?  And when you reach the end, should the Button1 be disabled ?

Share this post


Link to post
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. :)

 

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...