Sign in to follow this  
Followers 0
big_daddy

Help With Array Error

4 posts in this topic

I get this error:

Error: Array variable has incorrect number of subscripts or subscript dimension range exceeded.

With this code:

Func ReadKeys();read the keys from uninstall section

_GuiCtrlStatusBarSetText ($StatusBar1, ' Reading Registry Keys, Please Wait....')

Dim $List[1]Dim $Icon[1]

Dim $Status[1]

GUISetCursor(15, 1);set cursor to wait

$i = 1

While 1

$var = RegEnumKey($Key, $i)

If @error <> 0 Then ExitLoop

$List[$i - 1] = RegRead($Key & "\" & $var, "DisplayName")

If $List[$i - 1] = "" Then $List[$i - 1] = RegRead($Key & "\" & $var, "#DisplayName")

If $List[$i - 1] = "" Then $List[$i - 1] = "No Display Name"

$Icon[$i - 1] = RegRead($Key & "\" & $var, "DisplayIcon")

$Icon[$i - 1] = StringReplace(StringMid($Icon[$i - 1], 1, StringInStr($Icon[$i - 1], ',') - 1), '"', '')

If $Icon[$i - 1] = "" Then $Icon[$i - 1] = "SHELL32.DLL"

$Status[$i - 1] = RegRead($Key & "\" & $var, "QuietUninstallString") ;Getting an error here, can't figure out why?

If $Status[$i - 1] <= 1 Then

$Status[$i - 1] = ".\LedNone.ico"

Else

$Status[$i - 1] = ".\LedGreen.ico"

EndIf

$List[$i - 1] = $List[$i - 1] & '|' & $var & '|' & $Icon[$i - 1] & "|" & $Status[$i - 1]

ReDim $List[uBound($List) + 1]

ReDim $Icon[uBound($Icon) + 1]

ReDim $Icon[uBound($Status) + 1]

$i += 1

WEnd

ReDim $List[uBound($List) - 2]

ReDim $Icon[uBound($Icon) - 2]

ReDim $Icon[uBound($Status) - 2]

_ArraySort($List)

GUICtrlSetState($Progress1, $GUI_SHOW)

For $i = 1 To UBound($List)

GUICtrlSetData($Progress1, Int(($i / UBound($List)) * 100))

$Item = StringSplit($List[$i - 1], '|')

GUICtrlCreateListViewItem("" & "|" & $Item[1] & "|" & $Item[2] & "|", $ulist)

GUICtrlSetImage(-1, $Item[3])

;GUICtrlSetImage(???, $Item[4]);What ever the control id of the status column is.

Sleep(15)

Next

Sleep(1000)

_GuiCtrlStatusBarSetText ($StatusBar1, _GUICtrlListViewGetItemCount ($ulist) & ' Objects')

GUICtrlSetState($Progress1, $GUI_HIDE)

GUISetCursor(2, 1);set cursor to arrow

EndFunc;==>ReadKeys

Share this post


Link to post
Share on other sites



This is part of my add/remove programs script. I'm trying to include a status for if the reg key has a silent uninstall. I tried to pretty much duplicate the displayicon column, but for some reason I get the error above. Any have would be great.

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

This is part of my add/remove programs script. I'm trying to include a status for if the reg key has a silent uninstall. I tried to pretty much duplicate the displayicon column, but for some reason I get the error above. Any have would be great.

I assume you've already debugged it?
$Status[$i - 1] = RegRead($Key & "\" & $var, "QuietUninstallString") 
If @error <> 0 Then
    MsgBox(0, 'Debug', 'Problem Opening The Key')
Else
    MsgBox(0, 'Debug', 'Value = ' & $Status[$i - 1])
EndIf

I also used this for key (Is this right?)

$key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

Mine keeps showing a problem opening the key issue, when I try to simulate it, but shows the RegEnumKey() value.

Edit:

Weird, but now this works:

$Key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"

Dim $Status[1000000]
For $i = 1 To 1000000
    $var = RegEnumKey($Key, $i)
    $Status[$i - 1] = RegRead($Key & "\" & $var, "QuietUninstallString") 
    If $Status[$i - 1] <> '' Then
        MsgBox(0, '', $Key & "\" & $var, "QuietUninstallString")
        MsgBox(0, 'Debug', 'Value = ' & $Status[$i - 1])
    EndIf
Next

Edit2:

This seemed to work too:

$Key = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall"
Local $StatArray = ''
Local $a = 1
Do
    $StatArray = $StatArray & RegEnumKey($Key, $a) & Chr(01)
    $a += 1
Until RegEnumKey($Key, $a) = ''
Local $SplitStat = StringSplit(StringTrimRight($StatArray, 1), Chr(01))

For $i = 1 To UBound($SplitStat) - 1
    $Status = RegRead($Key & "\" & $SplitStat[$i], "QuietUninstallString") 
    If $Status <> '' Then
    ;MsgBox(0, '', $Key & "\" & $SplitStat[$i], "QuietUninstallString")
        MsgBox(0, 'Debug', 'Value = ' & $Status)
    EndIf
Next
Edited by SmOke_N

[center]Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.[/center]

Share this post


Link to post
Share on other sites

Thanks for the help. I remembered something danny35d told me about using double == when using IF THEN statements. I fixed that and now it seems to be working. Now I can't figure out how to set both the icon image and the silent status image.

It's using this to create the icon images:

GUICtrlSetImage(-1, $Item[3])

I'm not sure where that control id comes from. So I'm not sure what the control id of the silent column is. This is the whole script, if anyone has any ideas let me know.

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  
Followers 0