Quantcast
Channel: AutoIt v3 - Developer Chat
Viewing all articles
Browse latest Browse all 750

WEnd array error

$
0
0

After a search, I keep seeing answers "Upgrade to newer version of AutoIt" however I believe the error is still present in 3.3.12.0.

 

I don't believe this belongs in GHAS forum, as there is obviously an undealt with array out of bounds problem in my script, it's just that it could cause confusion when the error is pointing to the wrong place.
 
Here is the func it errors out on, it's not runnable on it's own of course.

AutoIt         
Func _LinksActual($Host)     $iHTMLArrayCurrentIndex = 4     $aHTMLArray[$iHTMLArrayCurrentIndex] = '4 - Link index<br><br>'     Local $iHostIndex = _ArraySearch($HostAndLinkArray, $Host, 0, 0, 0, 0, 1, 1)     If Not @error Then         Local $FoundHost = $HostAndLinkArray[$iHostIndex][0]         While $HostAndLinkArray[$iHostIndex][0] = $FoundHost             $HostSource = BinaryToString(InetRead($HostAndLinkArray[$iHostIndex][1]))             $Link = _StringBetween($HostSource, 'myButton" href="', '">Click')[0]             $aHTMLArray[$iHTMLArrayCurrentIndex] &= '<a href="' & $Link & '">' & $Link & '</a><br>'             $iHostIndex += 1             Sleep(500)         WEnd         ;Wierd error here if no links actual are found         ;"C:\Documents and Settings\JOHN\Documents\AU3\Projects\WSB.au3" (16) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:         ;WEnd         ;WEnd^ ERROR     Else     EndIf     _IEBodyWriteHTML($aMainControl[$H_IEOBJ], $aHTMLArray[$iHTMLArrayCurrentIndex])     Return EndFunc   ;==>_LinksActual

The only thing I can see which could go wrong here which might cause this, is if the line 

While $HostAndLinkArray[$iHostIndex][0] = $FoundHost

EDIT:

 

Just for the record, it was that line erroring out, because it was fixed with 

Func _LinksActual($Host)     $iHTMLArrayCurrentIndex = 4     $aHTMLArray[$iHTMLArrayCurrentIndex] = '4 - Link index<br><br>'     Local $iHostIndex = _ArraySearch($HostAndLinkArray, $Host, 0, 0, 0, 0, 1, 1)     If Not @error Then         Local $FoundHost = $HostAndLinkArray[$iHostIndex][0]         While $iHostIndex < UBound($HostAndLinkArray) And $HostAndLinkArray[$iHostIndex][0] = $FoundHost             $HostSource = BinaryToString(InetRead($HostAndLinkArray[$iHostIndex][1]))             $Link = _StringBetween($HostSource, 'myButton" href="', '">Click')[0]             $aHTMLArray[$iHTMLArrayCurrentIndex] &= '<a href="' & $Link & '">' & $Link & '</a><br>'             $iHostIndex += 1             Sleep(500)         WEnd     Else         $iHTMLArrayCurrentIndex -= 1         Return     EndIf     _IEBodyWriteHTML($aMainControl[$H_IEOBJ], $aHTMLArray[$iHTMLArrayCurrentIndex])     Return EndFunc   ;==>_LinksActual

Viewing all articles
Browse latest Browse all 750

Latest Images

Trending Articles



Latest Images