Radimus
(KiX Supporter)
2003-03-15 02:11 AM
I need a ubound of a object handle

I'm doing
$Computers = GetObject($ldap)
for each $item in $computers
next

but I need to know how many objects are in $computers first... I want to put a progressbar integral to the for each.

$max=ubound($computers) doesn't work

[ 15. March 2003, 02:12: Message edited by: Radimus ]


Glenn BarnasAdministrator
(KiX Supporter)
2003-03-15 02:18 AM
Re: I need a ubound of a object handle

My, you're feeling awfuly "needy" this evening. [Big Grin]

First thought is brute force..
code:
 
$iCnt = 0
For Each $ in $Computers
$iCnt = $iCnt + 1
Next
"Found $iCnt computers..."

But isn't $Computers an ordinary array? Any idea why UBound() won't work?

Gotta go raise my sugar level before I give ya any more brain cells.

Glenn


Sealeopard
(KiX Master)
2003-03-15 02:28 AM
Re: I need a ubound of a object handle

How about
code:
$Computers = GetObject($ldap)
$count=$computers.Count



[ 15. March 2003, 02:28: Message edited by: sealeopard ]


Radimus
(KiX Supporter)
2003-03-15 02:38 AM
Re: I need a ubound of a object handle

I've tried:

$Computers = GetObject($area)
? $computers.count
? ubound($computers)
$max=0 for each $c in $computers $max=$max+1 next

the for each works, but it is kludgy...


Sealeopard
(KiX Master)
2003-03-15 02:46 AM
Re: I need a ubound of a object handle

Yes, the ubound will definitely not work as it's not an array. The .Count should work for anything that has been retrieved via WQL query in synchronus mode. It will not work in semi-synchronous or asynchronous mode. I actually do
code:
$Computers = GetObject($area)
dim $comparray
for each $c in $computers
redim $comparray[ubound($comparray)+1]
$comparray[ubound($comparray)]=$c
next
? ubound($comparray)

This way I end up with an array or objects, e.g. $comparray[0].value (I believe). Check the ReadEventlog() UDF, I'm using it in there.


Howard Bullock
(KiX Supporter)
2003-03-15 02:54 AM
Re: I need a ubound of a object handle

Anybody good at using ADO and LDAP SQL dialect? Can one "select count from a collection"?

Example SQL dialect:

Select ADsPath, cn FROM 'LDAP://O=Internet/DC=COM/DC=ARCADIABAY/DC=ARCADIADEV' where objectClass='group'


Sealeopard
(KiX Master)
2003-03-15 03:02 AM
Re: I need a ubound of a object handle

Maybe
code:
Select Count(ADsPath) FROM 'LDAP://O=Internet/DC=COM/DC=ARCADIABAY/DC=ARCADIADEV' where objectClass='group'

?

Just shooting from the hip [Smile]