Jump to content

array (subscript dimension range exceeded.)


Jochem
 Share

Recommended Posts

sometimes I get this error, but not always, An I really don`t understand why:

(64) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.:

If StringLeft($aCompListA[$n], 4) = "ws-m" Then _ArrayDelete($aCompListA, $n)

If StringLeft(^ ERROR

Do I do something wrong?

Global $aCompListA = _netwerklist(0x1)
_ArraySort($aCompList)
For $n = UBound($aCompListA) - 1 To 0 Step -1
    If StringLeft($aCompListA[$n], 4) = "ws-c" Then _ArrayDelete($aCompListA, $n)
    If StringLeft($aCompListA[$n], 4) = "ws-l" Then _ArrayDelete($aCompListA, $n)
    If StringLeft($aCompListA[$n], 4) = "ws-m" Then _ArrayDelete($aCompListA, $n)
    If StringLeft($aCompListA[$n], 4) = "ws-g" Then _ArrayDelete($aCompListA, $n)
    If StringLeft($aCompListA[$n], 4) = "ws-v" Then _ArrayDelete($aCompListA, $n)
Next
Edited by Jochem
Link to comment
Share on other sites

Try this

Global $aCompList = _netwerklist(0x1)
#include<array.au3> ;; For testing with _ArrayDisplay() only.
_ArraySort($aCompList)
$aHold = $aCompList
For $n = UBound($aHold) - 1 To 0 Step -1
    If StringLeft($aHold[$n], 4) = "ws-c" Then _ArrayDelete($aCompListA, $n)
    If StringLeft($aHold[$n], 4) = "ws-l" Then _ArrayDelete($aCompListA, $n)
    If StringLeft($aHold[$n], 4) = "ws-m" Then _ArrayDelete($aCompListA, $n)
    If StringLeft($aHold[$n], 4) = "ws-g" Then _ArrayDelete($aCompListA, $n)
    If StringLeft($aHold[$n], 4) = "ws-v" Then _ArrayDelete($aCompListA, $n)
Next
_ArrayDisplay($aCompList)

Edit: Actually if I knew how you were getting the array to bigin with then I think there is a much easier way to do this whole thing particularily if the original data is contained in a "flat" file like a text file.

Example, copy the following to your clipboard

================

ws-c some crap

ws-b some crap

ws-r some crap

ws-l some crap

ws-m some crap

ws-g some crap

ws-v some crap

ws-d some crap

ws-p some crap

ws-t some crap

ws-n some crap

================

Now Run This code

#Include<array.au3>

$aCompList = StringRegExp(ClipGet(), "(?i)(ws\-[^gvmlc].*)(?:\v*|\z)", 3)
If NOT @Error Then
    _ArraySort($aCompList)
    _ArrayDisplay($aCompList)
Else
    MsgBox(0, "Error", "The SRE failed with error " & @Error)
EndIf
Edited by GEOSoft

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

Try this

Global $aCompList = _netwerklist(0x1)
#include<array.au3> ;; For testing with _ArrayDisplay() only.
_ArraySort($aCompListA)
$aHold = $aCompList
For $n = UBound($aHold) - 1 To 0 Step -1
    If StringLeft($aHold[$n], 4) = "ws-c" Then _ArrayDelete($aCompListA, $n)
    If StringLeft($aHold[$n], 4) = "ws-l" Then _ArrayDelete($aCompListA, $n)
    If StringLeft($aHold[$n], 4) = "ws-m" Then _ArrayDelete($aCompListA, $n)
    If StringLeft($aHold[$n], 4) = "ws-g" Then _ArrayDelete($aCompListA, $n)
    If StringLeft($aHold[$n], 4) = "ws-v" Then _ArrayDelete($aCompListA, $n)
Next
_ArrayDisplay($aCompList)

thanks; this is working!!

this how i retrieve a list of all computers on the network; but I have to split up this array for cad-computer and for servers and for.... etc.

So I copy the retrieved array couple of times and than delete the not wanted items, to get array`s for the specific groups.

Func _netwerklist($iSrvType = -1, $sDomain = '')
    Local $uBufPtr = DllStructCreate("ptr;int;int"), $res[1] = [0], $i
    Local $uRecord = DllStructCreate("dword;ptr"), $iRecLen = DllStructGetSize($uRecord)
    Local $uString = DllStructCreate("char[16]")
    Local $uDomain = DllStructCreate("byte[32]"), $pDomain = 0
    If Not ($sDomain = '' Or $sDomain = '*') Then
        DllStructSetData($uDomain, 1, StringToBinary($sDomain, 2))
        $pDomain = DllStructGetPtr($uDomain)
    EndIf
    Local $ret = DllCall("netapi32.dll", "int", "NetServerEnum", _
            "ptr", 0, "int", 100, _
            "ptr", DllStructGetPtr($uBufPtr, 1), "int", -1, _
            "ptr", DllStructGetPtr($uBufPtr, 2), _
            "ptr", DllStructGetPtr($uBufPtr, 3), _
            "int", $iSrvType, "ptr", $pDomain, "int", 0)
    If $ret[0] Then Return SetError(1, $ret[0], '')
    Local $res[DllStructGetData($uBufPtr, 3) + 1] = [DllStructGetData($uBufPtr, 3)]
    For $i = 1 To DllStructGetData($uBufPtr, 3)
        Local $uRecord = DllStructCreate("dword;ptr", DllStructGetData($uBufPtr, 1) + ($i - 1) * $iRecLen)
        Local $sNBName = DllStructCreate("byte[32]", DllStructGetData($uRecord, 2))
        DllStructSetData($uString, 1, BinaryToString(DllStructGetData($sNBName, 1), 2))
        $res[$i] = DllStructGetData($uString, 1)
    Next
    $ret = DllCall("netapi32.dll", "int", "NetApiBufferFree", "ptr", DllStructGetData($uBufPtr, 1))
    Return $res
EndFunc   ;==>_netwerklist
Edited by Jochem
Link to comment
Share on other sites

thanks; this is working!!

No problem but read my edit before you go too far.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

#Include<array.au3>
Global $aCompList = _netwerklist(0x1)
$sCompList = _ArrayToString($aCompList, @CRLF)
$aHold = StringRegExp($sCompList, "(?i)(ws\-[^gvmlc].*)(?:\v*|\z)", 3)
If NOT @Error Then
    _ArraySort($aHold)
    $aCompList = $aHold
    _ArrayDisplay($aCompList)
Else
    MsgBox(0, "Error", "The SRE failed with error " & @Error)
EndIf

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

#Include<array.au3>
Global $aCompList = _netwerklist(0x1)
$sCompList = _ArrayToString($aCompList, @CRLF)
$aHold = StringRegExp($sCompList, "(?i)(ws\-[^gvmlc].*)(?:\v*|\z)", 3)
If NOT @Error Then
    _ArraySort($aHold)
    $aCompList = $aHold
    _ArrayDisplay($aCompList)
Else
    MsgBox(0, "Error", "The SRE failed with error " & @Error)
EndIf

good script! but after every string in the array I get a little squared block like a "enter"? or something

this did the tric

$sCompList = _ArrayToString($aCompList, @LF)
Edited by Jochem
Link to comment
Share on other sites

It should probably have been this.

$aHold = StringRegExp($sCompList, "(?i)(ws\-[^gvmlc].*)(?:\v|\z)", 3)

Using the @LF does the same thing though so just stay with it.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

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