Jump to content

does _arrayadd support multiple dimensions?


gcue
 Share

Recommended Posts

heres what im trying to do...

Global $results[1] = [0]

and later im trying to add to the array

for $x = 1 to $ret[0]

$apps = IniReadSection($cINI, "APPLICATIONS")

for $a=1 to $apps[0][0]

if $apps[$a][0] = $ret[$x] then

_ArrayAdd($results, $apps[$a][0], " installed")

EndIf

Next

next

Link to comment
Share on other sites

It should set the @error to 2 as noted in the help file because it's not an 1 dimensional array.

Yeah, from that I'd assume it doesn't support multiple dimensions... qcue will hafta ReDim his array with each loop and keep adding to it.

Edited by exodius
Link to comment
Share on other sites

ok im confused.. can i add a two dimensional array? if so how?

not sure what you meant here:

"ReDim his array with each loop and keep adding to it."

LOL, wait a second, now that I actually look at your code, your end-result array you're using _ArrayAdd on doesn't appear to be multi-dimensional, so why the question?

Global $results[1] = [0] ; <-- Why is the 0 in brackets?

For $x = 1 To $ret[0]
    $apps = IniReadSection($cINI, "APPLICATIONS")
    For $a = 1 To $apps[0][0]
        If $apps[$a][0] = $ret[$x] Then 

            _ArrayAdd($results, $apps[$a][0], " installed")
        EndIf
    Next
Next

Are you getting an error when you try to do that _ArrayAdd?

Edited by exodius
Link to comment
Share on other sites

yep

Ah hah!

When you do:

_ArrayAdd($results, $apps[$a][0], " installed")oÝ÷ Ù.ßÚÞ}çx"·wb}÷«z{ij¶¦z׫±·jëÊ¡j÷¶r¦jÀ+­¬uÚ'&qêm³jZ­©µê춮¶²Ê·ö·uاÚÛazö¥¹ì¨»ky§]x£¢ëZºÚ"µÍÐ^PY
    ÌÍÜÝ[Ë ÌÍØÖÉÌÍØWVÌH   [È ][ÝÈ[Ý[Y ][ÝÊHÈ   ËKHÝXÙHH[Ø[ÈÛÛØ][]HH    ][ÝÚ[Ý[Y ][ÝÈÛ
Edited by exodius
Link to comment
Share on other sites

hmm that doesnt add another dimension/column tho

Okay, so we're back to my original line of thought. :)

Here's an example of how to ReDim an array manually. Bear in mind that your array always has to be declared one # higher than the actual # of indexes you're going to use.

Dim $array[1]
$array[0] = "Test"

For $x = 0 To UBound($array)-1
    MsgBox (0, "Single Dimension Array", $array[$x])
Next

ReDim $array[1][1]

$array[0][0] = "Also Test"

For $x = 0 To UBound($array)-1
    MsgBox (0, "Double Dimension Array - 1 Entry", $array[$x][$x])
Next

ReDim $array[2][2]

$array[0][0] = "And So We'll Test"
$array[1][1] = "Testing Again"

For $x = 0 To UBound($array)-1
    MsgBox (0, "Double Dimension Array - 2 Entries", $array[$x][$x])
Next
Link to comment
Share on other sites

There were functions posted for 2D array support in __ArrayAdd() and _ArrayConcatenate() in the topic: howto add rows to an array?

The bird that wrote them is not that bright, but very good looking, so they must work!

:)

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
Link to comment
Share on other sites

actually i think im gonna go a different route.. a csv file for results is easier to use

i am having trouble with my if/for statements

this is supposed to check if an application is installed on a pc:

(ini lists an application list under a section called applications)

i want to report back if the app is installed on the pc or not, YES works but NO doesnt

not sure how to code the NO part

$asset = "localhost"
$app_found = False

$ret = _InstalledSoftware($asset)
_ArraySort($ret)

For $x = 1 To $ret[0]
    $apps = IniReadSection($cINI, "APPLICATIONS")
    For $a = 1 To $apps[0][0]
        If $apps[$a][0] = $ret[$x] Then
            $app_found = True
            FileWrite($file, "" & @CRLF & _
                    $asset & "," & $apps[$a][0] & "," & "YES")
                EndIf
    Next    
Next
ShellExecute($file)
Edited by gcue
Link to comment
Share on other sites

actually i think im gonna go a different route.. a csv file for results is easier to use

i am having trouble with my if/for statements

this is supposed to check if an application is installed on a pc:

(ini lists an application list under a section called applications)

i want to report back if the app is installed on the pc or not, YES works but NO doesnt

not sure how to code the NO part

How about:

$asset = "localhost"
$app_found = False

$ret = _InstalledSoftware($asset)
_ArraySort($ret)

For $x = 1 To $ret[0]
    $apps = IniReadSection($cINI, "APPLICATIONS")
    For $a = 1 To $apps[0][0]
        If $apps[$a][0] = $ret[$x] Then
            $app_found = True
            FileWrite($file, "" & @CRLF & _
                    $asset & "," & $apps[$a][0] & "," & "YES")
        Else
            MsgBox (0, "", "Application Not Installed!")
        EndIf
    Next
Next
ShellExecute($file)
Link to comment
Share on other sites

thanks for replying.

i tried that but i when it compares the appname to the applist in the array, only one will be accurate and the rest will be NO..

so i tried this which gave me better results but still not working correctly

$ret = _InstalledSoftware($asset)
_ArraySort($ret)

$app_found = False

For $x = 1 To $ret[0]
    $apps = IniReadSection($cINI, "APPLICATIONS")
    For $a = 1 To $apps[0][0]
        If $apps[$a][0] = $ret[$x] Then
            $app_found = True
            FileWrite($results, "" & @CRLF & _
                    $asset & "," & $apps[$a][0] & "," & "YES")
        ElseIf $app_found = False Then
            FileWrite($results, "" & @CRLF & _
                    $asset & "," & $apps[$a][0] & "," & "NO")
        EndIf
    Next
Next
Link to comment
Share on other sites

Ah, I'm on your wavelength now:

*Edit = You don't need to call the IniReadSection function everytime you go through that loop.

*Edit2 = Had to re-place a variable.

$ret = _InstalledSoftware($asset)
_ArraySort($ret)

$apps = IniReadSection($cINI, "APPLICATIONS")
For $x = 1 To $ret[0]
    $app_found = False
    For $a = 1 To $apps[0][0]
        If $apps[$a][0] = $ret[$x] Then
            $app_found = True
            ExitLoop
        EndIf
    Next
    
    If $app_found = True Then
        FileWrite($results, "" & @CRLF & _
                $asset & "," & $apps[$a][0] & "," & "YES")
    Else
        FileWrite($results, "" & @CRLF & _
                $asset & "," & $apps[$a][0] & "," & "NO")
    EndIf
Next
Edited by exodius
Link to comment
Share on other sites

hmm i get an error and i think i see why

$apps[$a][0] is outside the For loop that defines it so it has no idea what that is...

i tried within the For loop - same prob as before =/

Edited by gcue
Link to comment
Share on other sites

hmm i get an error and i think i see why

$apps[$a][0] is outside the For loop that defines it so it has no idea what that is...

i tried within the For loop - same prob as before =/

See if that shines any light on things, otherwise, see what line SciTE says is breaking it.

$ret = _InstalledSoftware($asset)
_ArraySort($ret)
_ArrayDisplay($ret)

$apps = IniReadSection($cINI, "APPLICATIONS")
If @error Then 
    MsgBox(4096, "", "Error occurred, probably no INI file.")
Else
    _ArrayDisplay($apps)
    For $x = 1 To $ret[0]
        $app_found = False
        For $a = 1 To $apps[0][0]
            If $apps[$a][0] = $ret[$x] Then
                $app_found = True
                ExitLoop
            EndIf
        Next
       
        If $app_found = True Then
            FileWrite($results, "" & @CRLF & _
                    $asset & "," & $apps[$a][0] & "," & "YES")
        Else
            FileWrite($results, "" & @CRLF & _
                    $asset & "," & $apps[$a][0] & "," & "NO")
        EndIf
    Next
EndIf
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...