Jump to content

Recommended Posts

Posted

is there a way to display only certain values in an arraydisplay? here's a screenshot of what my current arraydisplay looks like

http://www.postyourimage.com/view_image.ph...CtZPi1215519674

i would like to only display those values that equal zero in column 2.

here is my code (using a new HKCU UDF - http://www.autoitscript.com/forum/index.ph...p;#entry545798)

#include <Array.au3>
#include "HKCUReg.au3"

$sComputer = "d0079214"

For $i = 1 To 100
    $b = _HKCU_EnumKey("\\\" & $sComputer & "\Network", $i)
;$c = _HKCU_Read("\\\" & $sComputer & "\Network\" & $i, "RemotePath")
    $iProd = 1
    For $j = 1 To $b[0][0]
        $iProd *= $b[$j][2]
    Next
    If $iProd <> 0 Then ExitLoop

    _ArrayDisplay($b)
Next
Posted

Before performing the _ArrayDisplay(), run a For...Next loop to search through the Array and run an _ArrayDelete() against any elements that do not match 0 for the 3rd element in your 2D array.

Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Posted

what does that look like??

arraysearch then arraydelete

sorry havent doen this before

#include <Array.au3>
#include "HKCUReg.au3"

$sComputer = "d0079214"

For $i = 1 To 100
    $b = _HKCU_EnumKey("\\\" & $sComputer & "\Network", $i)
    For $k = 1 To $b[0][0]
        If $b[$k][2] <> 0 Then
            _ArrayDelete($b,$k)
        EndIf
    Next
;$c = _HKCU_Read("\\\" & $sComputer & "\Network\" & $i, "RemotePath")
    $iProd = 1
    For $j = 1 To $b[0][0]
        $iProd *= $b[$j][2]
    Next
    If $iProd <> 0 Then ExitLoop

    _ArrayDisplay($B)
Next
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Posted

hmm i got an error: "arry variable has incorrect number of subscripts or subscript dimension range exceeded."

thanks for your help!

Posted

hmm i got an error: "arry variable has incorrect number of subscripts or subscript dimension range exceeded."

thanks for your help!

Your enum didn't return any values (meaning there is no Network key in HKCU). I also forgot about the [0][0] index needing to me modified after the delete. Try this:

#include <Array.au3>
#include "HKCUReg.au3"

$sComputer = "d0079214"

For $i = 1 To 100
    $b = _HKCU_EnumKey("\\\" & $sComputer & "\Software", $i)
    For $k = 1 To $b[0][0]
        If $b[$k][2] <> 0 Then
            _ArrayDelete($b,$k)
            $b[0][0] -= 1
        EndIf
    Next
;$c = _HKCU_Read("\\\" & $sComputer & "\Network\" & $i, "RemotePath")
    $iProd = 1
    For $j = 1 To $b[0][0]
        $iProd *= $b[$j][2]
    Next
    If $iProd <> 0 Then ExitLoop

    _ArrayDisplay($B)
Next
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Posted (edited)

Software works.

Network should work as shown in the screenshot, there are some values that will have 0 in the third value...hmm maybe im getting an error bc it doesnt know how to handle the value that equals -1?

Edited by gcue
Posted

Software works.

Network should work as shown in the screenshot, there are some values that will have 0 in the third value...hmm maybe im getting an error bc it doesnt know how to handle the value that equals -1?

It was stopping at the beginning of the For loop on my machine, because my HKCU\Network key is empty. The only reason you'll get the error you were seeing is if the array value referenced does not exist (i.e. $b[0][0] is invalid because the array is not 2D or it is empty).
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Posted

on some values it will be empty, but again as shown on the screenshot i provided

(http://www.postyourimage.com/view_image.php?img_id=NpBhbJiCCtZPi1215519674)

there are some values should hold true

thanks again for your help

Posted

on some values it will be empty, but again as shown on the screenshot i provided

(http://www.postyourimage.com/view_image.php?img_id=NpBhbJiCCtZPi1215519674)

there are some values should hold true

thanks again for your help

I was just explaining what I encountered in my testing; I know your Network key isn't empty as referenced in the screenshot. Did you try the example again after I added the $b[0][0] -= 1 line?
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Posted

yea this is what im running:

#include <Array.au3>
#include "HKCUReg.au3"

$sComputer = "d0079214"

For $i = 1 To 100
    $b = _HKCU_EnumKey("\\\" & $sComputer & "\Network", $i)
    
    
    For $k = 1 To $b[0][0]
        If $b[$k][2] <> 0 Then
            _ArrayDelete($b,$k)
            $b[0][0] -= 1
        EndIf
    Next

    
;$c = _HKCU_Read("\\\" & $sComputer & "\Network\" & $i, "RemotePath")
    $iProd = 1
    For $j = 1 To $b[0][0]
        $iProd *= $b[$j][2]
    Next
    If $iProd <> 0 Then ExitLoop


    _ArrayDisplay($b)
Next
Posted

For...Next statements may be nested. The For loop terminates when the value of variable exceeds the stop threshold. If stepVal or stop is a variable, its value is only read the first time the loop executes.

Try looping backwards so you don't shoot yourself in the foot.
For $k = $b[0][0] to 1 Step -1
    If $b[$k][2] <> 0 Then
        _ArrayDelete($b,$k)
        $b[0][0] -= 1
    EndIf
Next

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Posted

Try looping backwards so you don't shoot yourself in the foot.

For $k = $b[0][0] to 1 Step -1
    If $b[$k][2] <> 0 Then
        _ArrayDelete($b,$k)
        $b[0][0] -= 1
    EndIf
Next
Ah, yes. That is the better way to do it. I don't know why I didn't think about stepping backwards earlier today.
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Posted

i still get the error =/

I figured you would. The problem seems to be with the $b array returned from the _HKCU_EnumKey() function. Try it with a different key (like Software) just to see if it works. It works on my machine; I'd test the Network key, but mine is empty.
Certifications: A+, Network+, Security+, Linux+, LPIC-1, MCSA | Languages: AutoIt, C, SQL, .NETBooks: AutoIt v3: Your Quick Guide - $7.99 - O'Reilly Media - September 2007-------->[u]AutoIt v3 Development - newbie to g33k[/u] - Coming Soon - Fate Publishing - Spring 2013UDF Libraries: SkypeCOM UDF Library | ADUC Computers OU Cleanup | Find PixelChecksumExamples: Skype COM Examples - Skype4COMLib Examples converted from VBS to AutoIt
Posted

software works =)

can you try to add a dummy value? you can by mapping a drive and selecting reconnect at login (this would add a value to Network)

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...