Jump to content
Sign in to follow this  
gcue

declaring a multi-dimensional array

Recommended Posts

gcue

i dont know how many records the array will have so how do i declare the array in the beginning?

(trying to inject into the array)

i DO know how many columns there will be but not how many rows... not sure if that makes a difference...

Dim $hkcu_array_yes[0][0], $hkcu_array_no[0][0]

                $reg_read = _HKCU_Read("\\\" & $asset & $dir, $fn)
                For $i = 1 To $reg_read[0][0]
                    $reg_found = False
                    If $reg_read[$i][1] = $regs[$r][1] Then
                        If $reg_read[$i][0] <> "svcAltiris_DS" And $reg_read[$i][0] <> "Default User" Then
                            $hkcu_array_yes[$i][0] = $asset_label
                            $hkcu_array_yes[$i][1] = $asset
                            $hkcu_array_yes[$i][2] = $reg_read[$i][0]
                            $hkcu_array_yes[$i][3] = $regs[$r][0]
                            $hkcu_array_yes[$i][4] = "YES"
                            $hkcu_array_yes[$i][5] = ""
                            $hkcu_array_yes[$i][6] = $regnote
                        EndIf
                        $reg_found = True
                        ContinueLoop
                    EndIf
                                                                      Next
Edited by gcue

Share this post


Link to post
Share on other sites
KaFu

Not enough code for a qualified answer, try something like

If $reg_read[$i][0] <> "svcAltiris_DS" And $reg_read[$i][0] <> "Default User" Then
redim $hkcu_array_yes[ubound($hkcu_array_yes)+1][7]
$hkcu_array_yes[ubound($hkcu_array_yes)-1][0] = $asset_label
$hkcu_array_yes[ubound($hkcu_array_yes)-1][1] = $asset
....

Share this post


Link to post
Share on other sites
gcue

i get an error: "array variable subscript badly formatted"

sorry i didnt post more code, didnt want to inundate you, what part of it do you want? (figured this was enough, isnt it?)

Dim $hkcu_array_yes[0][0]

                $reg_read = _HKCU_Read("\\\" & $asset & $dir, $fn)
                For $i = 1 To $reg_read[0][0]
                    $reg_found = False
                    If $reg_read[$i][1] = $regs[$r][1] Then
                        If $reg_read[$i][0] <> "svcAltiris_DS" And $reg_read[$i][0] <> "Default User" Then

                            ReDim $hkcu_array_yes[UBound($hkcu_array_yes) + 1][7]

                            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][0] = $asset_label
                            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][1] = $asset
                            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][2] = $reg_read[$i][0]
                            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][3] = $regs[$r][0]
                            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][4] = "YES"
                            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][5] = ""
                            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][6] = $regnote

                        EndIf
                        $reg_found = True
                        ContinueLoop
                    EndIf
                NextoÝ÷ Ú&¥²kçZºÚ"µÍBBBBBBBQ[H    ÌÍÚØÝWØ^WÞYÖÌVÌK  ÌÍÚØÝWØ^WÛÖÌVÌBBBBIÌÍÜY×ÜXYHÒÐÕWÔXY
    ][ÝÉÌLÉÌLÉÌLÉ][ÝÈ [È ÌÍØÜÙ] [È ÌÍÙ  ÌÍÙBBBBQÜ   ÌÍÚHHHÈ ÌÍÜY×ÜXYÌVÌBBBBBIÌÍÜY×ÙÝ[H[ÙBBBBBRY   ÌÍÜY×ÜXYÉÌÍÚWVÌWHH    ÌÍÜYÜÖÉÌÍÜVÌWH[BBBBBRY    ÌÍÜY×ÜXYÉÌÍÚWVÌH  ÉÝÈ  ][ÝÜÝÐ[×ÑÉ][ÝÈ[    ÌÍÜY×ÜXYÉÌÍÚWVÌH  ÉÝÈ  ][ÝÑY][Ù][ÝÈ[BBBBBBTQ[H    ÌÍÚØÝWØ^WÞYÖÕPÝ[
    ÌÍÜY×ÜXY
H
ÈWVÍ×BBBBBBBIÌÍÚØÝWØ^WÞYÖÕPÝ[
    ÌÍÜY×ÜXY
HHWVÌHH    ÌÍØÜÙ]ÛX[BBBBBBIÌÍÚØÝWØ^WÞYÖÕPÝ[
    ÌÍÜY×ÜXY
HHWVÌWHH   ÌÍØÜÙ]BBBBBBIÌÍÚØÝWØ^WÞYÖÕPÝ[
    ÌÍÜY×ÜXY
HHWVÌHH    ÌÍÜY×ÜXYÉÌÍÚWVÌBBBBBBBIÌÍÚØÝWØ^WÞYÖÕPÝ[
    ÌÍÜY×ÜXY
HHWVÌ×HH  ÌÍÜYÜÖÉÌÍÜVÌBBBBBBBIÌÍÚØÝWØ^WÞYÖÕPÝ[
    ÌÍÜY×ÜXY
HHWVÍHH    ][ÝÖQTÉ][ÝÂBBBBBBIÌÍÚØÝWØ^WÞYÖÕPÝ[
    ÌÍÜY×ÜXY
HHWVÍWHH   ][ÝÉ][ÝÂBBBBBBIÌÍÚØÝWØ^WÞYÖÕPÝ[
    ÌÍÜY×ÜXY
HHWVÍHH    ÌÍÜYÛÝBBBBBBQ[YBBBBBIÌÍÜY×ÙÝ[HYBBBBBBPÛÛ[YSÛÜBBBBQ[YBBBS^
Edited by gcue

Share this post


Link to post
Share on other sites
KaFu

Dim $hkcu_array_yes[1][1]
$hkcu_array_yes[0][0] = 0

$reg_read = _HKCU_Read("\\\" & $asset & $dir, $fn)
$reg_found = False

For $i = 1 To $reg_read[0][0]
    If $reg_read[$i][1] = $regs[$r][1] Then
        If $reg_read[$i][0] <> "svcAltiris_DS" And $reg_read[$i][0] <> "Default User" Then

            ReDim $hkcu_array_yes[UBound($hkcu_array_yes) + 1][7]

            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][0] = $asset_label
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][1] = $asset
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][2] = $reg_read[$i][0]
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][3] = $regs[$r][0]
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][4] = "YES"
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][5] = ""
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][6] = $regnote

            $hkcu_array_yes[0][0] = UBound($hkcu_array_yes) - 1

        EndIf
    EndIf
Next

if $hkcu_array_yes[0][0] > 0 then $reg_found = True

Share this post


Link to post
Share on other sites
evilertoaster

The code for _HKCU_Read() might be useful...

What about your for loop, should you be doing For $i = 0 To $reg_read[0][0] ?

Share this post


Link to post
Share on other sites
gcue

this works great!!!

how about if i query several reg entries.. currently only the last reg query is in the array...

Dim $hkcu_array_yes[1][1]
$hkcu_array_yes[0][0] = 0

$reg_read = _HKCU_Read("\\\" & $asset & $dir, $fn)
$reg_found = False

For $i = 1 To $reg_read[0][0]
    If $reg_read[$i][1] = $regs[$r][1] Then
        If $reg_read[$i][0] <> "svcAltiris_DS" And $reg_read[$i][0] <> "Default User" Then

            ReDim $hkcu_array_yes[UBound($hkcu_array_yes) + 1][7]

            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][0] = $asset_label
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][1] = $asset
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][2] = $reg_read[$i][0]
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][3] = $regs[$r][0]
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][4] = "YES"
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][5] = ""
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][6] = $regnote

            $hkcu_array_yes[0][0] = UBound($hkcu_array_yes) - 1

        EndIf
    EndIf
Next

if $hkcu_array_yes[0][0] > 0 then $reg_found = True

Share this post


Link to post
Share on other sites
gcue

The code for _HKCU_Read() might be useful...

What about your for loop, should you be doing For $i = 0 To $reg_read[0][0] ?

here is a link to that HKCU (its engine's UDF)

#545798

the for loop thing.. should i use ubound?

Share this post


Link to post
Share on other sites
KaFu

Hmm, I still not quiet sure what $reg_read[0][0] contains.

Add a msgbox(0,"",$reg_read[0][0] & @crlf & ubound($reg_read)-1) after the _HKCU_Read() to check if it's the number of returned elements.

For multiple queries just add up the _HKCU_Read() calls like this:

Dim $hkcu_array_yes[1][1]
$hkcu_array_yes[0][0] = 0
$reg_found = False

$reg_read = _HKCU_Read("\\\" & $asset & $dir, $fn)

For $i = 1 To $reg_read[0][0]
    If $reg_read[$i][1] = $regs[$r][1] Then
        If $reg_read[$i][0] <> "svcAltiris_DS" And $reg_read[$i][0] <> "Default User" Then

            ReDim $hkcu_array_yes[UBound($hkcu_array_yes) + 1][7]

            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][0] = $asset_label
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][1] = $asset
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][2] = $reg_read[$i][0]
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][3] = $regs[$r][0]
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][4] = "YES"
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][5] = ""
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][6] = $regnote

            $hkcu_array_yes[0][0] = UBound($hkcu_array_yes) - 1

        EndIf
    EndIf
Next

$reg_read = _HKCU_Read("\\\" & $asset & $dir, $fn)

For $i = 1 To $reg_read[0][0]
    If $reg_read[$i][1] = $regs[$r][1] Then
        If $reg_read[$i][0] <> "svcAltiris_DS" And $reg_read[$i][0] <> "Default User" Then

            ReDim $hkcu_array_yes[UBound($hkcu_array_yes) + 1][7]

            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][0] = $asset_label
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][1] = $asset
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][2] = $reg_read[$i][0]
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][3] = $regs[$r][0]
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][4] = "YES"
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][5] = ""
            $hkcu_array_yes[UBound($hkcu_array_yes) - 1][6] = $regnote

            $hkcu_array_yes[0][0] = UBound($hkcu_array_yes) - 1

        EndIf
    EndIf
Next

if $hkcu_array_yes[0][0] > 0 then $reg_found = True

Share this post


Link to post
Share on other sites
gcue

actually to better illustrate.. hers the same query done with local machine...

it only keeps the last query done. (ive also included where $regs comes from - sorry bout that)

$regs = IniReadSection($cfg, "REGISTRY")
    _ArraySort($regs)
    If not @error Then

                Dim $hklm_array_yes[1][1], $hklm_array_no[1][1]

                $hklm_array_yes[0][0] = 0
                $hklm_array_no[0][0] = 0

                $reg_read = RegRead("\\" & $asset & "\" & $dir, $fn)
                If $regs[$r][1] = $reg_read Then

                    ReDim $hklm_array_yes[UBound($hklm_array_yes) + 1][6]

                    $hklm_array_yes[UBound($hklm_array_yes) - 1][0] = $asset_label
                    $hklm_array_yes[UBound($hklm_array_yes) - 1][1] = $asset
                    $hklm_array_yes[UBound($hklm_array_yes) - 1][2] = $regs[$r][0]
                    $hklm_array_yes[UBound($hklm_array_yes) - 1][3] = "YES"
                    $hklm_array_yes[UBound($hklm_array_yes) - 1][4] = ""
                    $hklm_array_yes[UBound($hklm_array_yes) - 1][5] = $regnote

                    $reg_found = True
                    ContinueLoop
                EndIf
                
                If $reg_found = False Then
                    If $reg_read = "" Then
                        If $reg_read <> 0 Then
                            $reg_read = "<EMPTY>"
                        EndIf
                    EndIf

                    ReDim $hklm_array_no[UBound($hklm_array_no) + 1][6]

                    $hklm_array_no[UBound($hklm_array_no) - 1][0] = $asset_label
                    $hklm_array_no[UBound($hklm_array_no) - 1][1] = $asset
                    $hklm_array_no[UBound($hklm_array_no) - 1][2] = $regs[$r][0]
                    $hklm_array_no[UBound($hklm_array_no) - 1][3] = "YES"
                    $hklm_array_no[UBound($hklm_array_no) - 1][4] = ""
                    $hklm_array_no[UBound($hklm_array_no) - 1][5] = $regnote

                EndIf
endif
Edited by gcue

Share this post


Link to post
Share on other sites
PsaltyDS

i dont know how many records the array will have so how do i declare the array in the beginning?

(trying to inject into the array)

i DO know how many columns there will be but not how many rows... not sure if that makes a difference...

Dim $hkcu_array_yes[0][0], $hkcu_array_no[0][0]

                $reg_read = _HKCU_Read("\\\" & $asset & $dir, $fn)
                For $i = 1 To $reg_read[0][0]
                    $reg_found = False
                    If $reg_read[$i][1] = $regs[$r][1] Then
                        If $reg_read[$i][0] <> "svcAltiris_DS" And $reg_read[$i][0] <> "Default User" Then
                            $hkcu_array_yes[$i][0] = $asset_label
                            $hkcu_array_yes[$i][1] = $asset
                            $hkcu_array_yes[$i][2] = $reg_read[$i][0]
                            $hkcu_array_yes[$i][3] = $regs[$r][0]
                            $hkcu_array_yes[$i][4] = "YES"
                            $hkcu_array_yes[$i][5] = ""
                            $hkcu_array_yes[$i][6] = $regnote
                        EndIf
                        $reg_found = True
                        ContinueLoop
                    EndIf
                                                                      Next
Dude, haven't we been here before?

^_^


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

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  

×