Sign in to follow this  
Followers 0
Brenda1

create an array

11 posts in this topic

Hello Guys, is friday and I am complety lost! I need to put some information in one array (yes I know, as simple as that) this is my code:

$groups = $oUsr.groups  
    $tempbis = $oUsr.memberof
    
    For $groupname In $groups
        $test= $groupname.distinguishedname;this is what I want to put in the array
                                 $array= $array + $test
    Next

this is not working and I just want to use a simple array to get this information stored. Heeeeelp

Share this post


Link to post
Share on other sites



Check out _ArrayAdd in the helpfile :D


Broken link? PM me and I'll send you the file!

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Not being familiar with the data structure you are trying to add to the array, you may want to check out the UDF Array functions:

_ArrayAdd

_ArrayInsert

may be what you are looking for.

Bob

EDIT: what monoceres said :D

Edited by YellowLab

You can't see a rainbow without first experiencing the rain.

Share this post


Link to post
Share on other sites

Not being familiar with the data structure you are trying to add to the array, you may want to check out the UDF Array functions:

_ArrayAdd

_ArrayInsert

may be what you are looking for.

Bob

EDIT: what monoceres said :D

what I am getting with:

$test= $groupname.distinguishedname

is something like: "$test=Group;type;rights;servers" but one account can have many groups, thats why I want to store them in one array, I try to put this:

For $groupname In $groups
     $test= $groupname.distinguishedname
     _ArrayAdd($aArray,$test)
        
Next

but didn't wooork!!!! =(

Share this post


Link to post
Share on other sites

You declared $aArray as an array beforehand, right? You know, "Dim $aArray[0]"?

Share this post


Link to post
Share on other sites

You declared $aArray as an array beforehand, right? You know, "Dim $aArray[0]"?

yes I declared the array like this:

dim $aArray[0]
    $groups = $oUsr.groups 
    $tempbis = $oUsr.memberof
    
    For $groupname In $groups
        $test= $groupname.distinguishedname
        _ArrayAdd($aArray,$test)
    Next

and I got this error:

test.au3(24,26) : ERROR: _ArrayAdd(): undefined function.
        _ArrayAdd($aArray,$test)
        ~~~~~~~~~~~~~~~~~~~~~~~^

what I am doing is getting information for some accounts, I need to know which account belong to diferents "groups", with "$test= $groupname.distinguishedname" I get the info for just one group, but the accoun have differents groups, that is what I want to storage in the array, all the groups of each account.

Help me guys I don't know what is wrong

Share this post


Link to post
Share on other sites

yes I declared the array like this:

dim $aArray[0]
    $groups = $oUsr.groups 
    $tempbis = $oUsr.memberof
    
    For $groupname In $groups
        $test= $groupname.distinguishedname
        _ArrayAdd($aArray,$test)
    Next

and I got this error:

test.au3(24,26) : ERROR: _ArrayAdd(): undefined function.
        _ArrayAdd($aArray,$test)
        ~~~~~~~~~~~~~~~~~~~~~~~^

what I am doing is getting information for some accounts, I need to know which account belong to diferents "groups", with "$test= $groupname.distinguishedname" I get the info for just one group, but the accoun have differents groups, that is what I want to storage in the array, all the groups of each account.

Help me guys I don't know what is wrong

Two points:

1. You don't declare an array with 0 elements, so use Global $aArray[1] to declare it.

2. The _ArrayAdd() function is a User Defined Function (UDF) included in the Array.au3 file, so add this to the top of your script: #include <Array.au3>

:D


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

Why can't you declare a 0 length array? I thought that was allowed.

Share this post


Link to post
Share on other sites

Why can't you declare a 0 length array? I thought that was allowed.

I noticed just yesterday that SciTe issues a warning when you do this: "Warning - array badly formed".

Das Häschen benutzt Radar

Share this post


Link to post
Share on other sites

Huh, well that's something I didn't know. I'm just used to being able to declare 0 length arrays in other languages then probably.

Share this post


Link to post
Share on other sites

Two points:

1. You don't declare an array with 0 elements, so use Global $aArray[1] to declare it.

2. The _ArrayAdd() function is a User Defined Function (UDF) included in the Array.au3 file, so add this to the top of your script: #include <Array.au3>

:D

thank you so much for your help, I didn't know I coudn't declare arrays with 0 elements in autoIT, and yes the library was missing too. =)

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