Jump to content

_GUICtrlListView_AddArray - Error on Line 390 of include


 Share

Recommended Posts

Hi all,

Below is my script. What I am basically doing is want to create a GUI that has a List of Registry settings from a specific Key. Dump that into a list view column and then Dump the values of the registry keys into the second column. I want to eventually make the value editable and then submit any changes back to the registry.

The problem I am having is on the _GUICtrlListView_AddArray control. The array exists and can be displayed but when I get down to the Loop for the UBound I get this error:

Line 390 (File "C:\Program Files\Autoit3\Include\GuiListView.au3"):

DllStructSetData($tBuffer, "Text", #aItems[$iI][0])

DllStructSetData($tBuffer, "Text", ^ERROR

Error:Array Variables has incorrect number of subscripts or subscript dimensions range exceeded.

I thought this was to do with the naming convention change from the example in Help to the array names I had set up or that the number of rows were not being read from the array.

Heads up appreciated. Excuse the layout of the code.

#include "CompInfo.au3"
#include "Array.au3"
#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>


;Opt('MustDeclareVars', 1)
Global $aReg[1] [1] [1]
Global $aReg2 [1] [1]
Global $aReg3 [1] [1]

$RegKey = "HKEY_LOCAL_MACHINE\Software\Hispeed"
$num = 0

For $i = 1 to 100
$var = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\Hispeed", $i)
if @error <> 0 Then ExitLoop
;MsgBox(4096, "Value Name  #" & $i & " under in AutoIt3 key", $var)
_ArrayAdd ($aReg, $var)
$add = $num + 1
$num = $add
next

$x = $num

For $x = $num to 1 Step -1
        $key = $aReg[$x]
        $val = RegRead ($RegKey, $key)
        ;MsgBox (4096, "Result", $RegKey & "\" & $key & "\" & $val)
        _ArrayAdd ($aReg2, $RegKey & "\" & $key)
        _ArrayAdd ($aReg3, $val)
    Next


; --------------------------------------------------------------------------------------
Example()

Func Example()
    Local $add, $clear, $reglist, $close, $msg, $regtitle
    
    ; Create GUI
    GUICreate("ListView Add Array", 400, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    ;_GUICtrlListView_SetUnicodeFormat($hListView, False)
    GUISetState()
    
    _GUICtrlListView_AddColumn($hListView, "Key Name", 100)
    _GUICtrlListView_AddColumn($hListView, "Value", 100)
    
    _GUICtrlListView_SetItemCount($hListView, $num)
    
    For $iI = 0 To UBound($aReg2) - 1
        $aReg2[$num] = "Key Name" & $iI
    Next
    
    
    _GUICtrlListView_AddArray($hListView, $aReg2)   
    
    $add = GUICtrlCreateButton("Add", 64, 32, 75, 25)
    $clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25)
    $close = GUICtrlCreateButton("Exit", 64, 350, 175, 25)

    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()

        Select
            
            Case $msg = $close
                Exit
        EndSelect
    WEnd

EndFunc   ;==>Example
Edited by hispeed_mike
Link to comment
Share on other sites

Hi all,

Below is my script. What I am basically doing is want to create a GUI that has a List of Registry settings from a specific Key. Dump that into a list view column and then Dump the values of the registry keys into the second column. I want to eventually make the value editable and then submit any changes back to the registry.

The problem I am having is on the _GUICtrlListView_AddArray control. The array exists and can be displayed but when I get down to the Loop for the UBound I get this error:

Line 390 (File "C:\Program Files\Autoit3\Include\GuiListView.au3"):

DllStructSetData($tBuffer, "Text", #aItems[$iI][0])

DllStructSetData($tBuffer, "Text", ^ERROR

Error:Array Variables has incorrect number of subscripts or subscript dimensions range exceeded.

I thought this was to do with the naming convention change from the example in Help to the array names I had set up or that the number of rows were not being read from the array.

Heads up appreciated. Excuse the layout of the code.

#include "CompInfo.au3"
#include "Array.au3"
#include <GUIConstantsEx.au3>
#Include <GuiListView.au3>


;Opt('MustDeclareVars', 1)
Global $aReg[1] [1] [1]
Global $aReg2 [1] [1]
Global $aReg3 [1] [1]

$RegKey = "HKEY_LOCAL_MACHINE\Software\Hispeed"
$num = 0

For $i = 1 to 100
$var = RegEnumVal("HKEY_LOCAL_MACHINE\SOFTWARE\Hispeed", $i)
if @error <> 0 Then ExitLoop
;MsgBox(4096, "Value Name  #" & $i & " under in AutoIt3 key", $var)
_ArrayAdd ($aReg, $var)
$add = $num + 1
$num = $add
next

$x = $num

For $x = $num to 1 Step -1
        $key = $aReg[$x]
        $val = RegRead ($RegKey, $key)
        ;MsgBox (4096, "Result", $RegKey & "\" & $key & "\" & $val)
        _ArrayAdd ($aReg2, $RegKey & "\" & $key)
        _ArrayAdd ($aReg3, $val)
    Next


; --------------------------------------------------------------------------------------
Example()

Func Example()
    Local $add, $clear, $reglist, $close, $msg, $regtitle
    
    ; Create GUI
    GUICreate("ListView Add Array", 400, 300)
    $hListView = GUICtrlCreateListView("", 2, 2, 394, 268)
    ;_GUICtrlListView_SetUnicodeFormat($hListView, False)
    GUISetState()
    
    _GUICtrlListView_AddColumn($hListView, "Key Name", 100)
    _GUICtrlListView_AddColumn($hListView, "Value", 100)
    
    _GUICtrlListView_SetItemCount($hListView, $num)
    
    For $iI = 0 To UBound($aReg2) - 1
        $aReg2[$num] = "Key Name" & $iI
    Next
    
    
    _GUICtrlListView_AddArray($hListView, $aReg2)   
    
    $add = GUICtrlCreateButton("Add", 64, 32, 75, 25)
    $clear = GUICtrlCreateButton("Clear", 64, 72, 75, 25)
    $close = GUICtrlCreateButton("Exit", 64, 350, 175, 25)

    $msg = 0
    While $msg <> $GUI_EVENT_CLOSE
        $msg = GUIGetMsg()

        Select
            
            Case $msg = $close
                Exit
        EndSelect
    WEnd

EndFunc   ;==>Example

Done thanks for the Tip. Much easier to read.

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