Page 1 of 1 1
Topic Options
#42629 - 2003-07-09 10:07 AM IDispatch pointers problem.
Koen van der Aa Offline
Fresh Scripter

Registered: 2002-07-13
Posts: 7
When i run the following code i get the IDispatch pointers error code. Can somebody explain / help me what to do?

Code:
If INOU("LAPTOPS","@WKSTA") = 1 ? "Yes" Else ? "NO"
EndIf

Function:
FUNCTION InOU ($ouname, OPTIONAL $iscomputer) ; (Standalone version restricted to Windows 2000 and XP systems)
DIM $ouelement
IF Len($iscomputer) > 0
$iscomputer=1
ELSE
$iscomputer=0
ENDIF
$inou=0
IF Len($_inouuser) > 0 AND Len($_inoucomputer) > 0
IF $iscomputer = 0
IF $_inouuser = "Initialized but no OU available"
RETURN
ENDIF
FOR EACH $ouelement IN Split($_inouuser,",")
IF $ouelement = $ouname
$inou=1
ENDIF
NEXT
ELSE
IF $_inoucomputer = "Initialized but no OU available"
RETURN
ENDIF
FOR EACH $ouelement IN Split($_inoucomputer,",")
IF $ouelement = $ouname
$inou=1
ENDIF
NEXT
ENDIF
ELSE
$sysinfo=CreateObject("adsysteminfo")
IF Len($sysinfo) > 0
FOR EACH $ouelement IN Split($sysinfo.username,",")
IF Left($ouelement,3) = "OU="
$_inouuser=$_inouuser+Substr($ouelement,4)+","
IF $iscomputer = 0
IF Substr($ouelement,4) = $ouname
$inou=1
ENDIF
ENDIF
ENDIF
NEXT
IF Len($_inouuser) = 0
$_inouuser="Initialized but no OU available"
ENDIF
FOR EACH $ouelement IN Split($sysinfo.computername,",")
IF Left($ouelement,3) = "OU="
$_inoucomputer=$_inoucomputer+","+Substr($ouelement,4)
IF $iscomputer = 1
IF Substr($ouelement,4) = $ouname
$inou=1
ENDIF
ENDIF
ENDIF
NEXT
IF Len($_inoucomputer) = 0
$_inoucomputer="Initialized but no OU available"
ENDIF
ENDIF
ENDIF
ENDFUNCTION ; - InOU -

[ 09. July 2003, 10:08: Message edited by: Koen van der Aa ]

Top
#42630 - 2003-07-09 10:08 AM Re: IDispatch pointers problem.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
without even reading your code I can say with 99% certainty that you have object returned from some line to the console.
_________________________
!

download KiXnet

Top
#42631 - 2003-07-09 10:13 AM Re: IDispatch pointers problem.
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
ok, starting from up, first problem seemed to be:
code:
$sysinfo=CreateObject("adsysteminfo")
IF Len($sysinfo) > 0

the same thing as with outputting it to console.
if $sysinfo has an object (successfull creation) you will get this error.
len() is function for checking string lengths.
objects have no string lenghts.
as you place it in as string, the len tries to translate the object to string-valuetype and thus the error.

more proper way would be:
code:
$sysinfo=CreateObject("adsysteminfo")
IF @error
"couldn't create object: @error, @serror"
exit 1
endif

which stops the UDF execution when error occurs, otherwise execution is continued.
_________________________
!

download KiXnet

Top
#42632 - 2003-07-09 10:27 AM Re: IDispatch pointers problem.
Koen van der Aa Offline
Fresh Scripter

Registered: 2002-07-13
Posts: 7
Replacing IF Len($sysinfo) > 0 by
IF @error "couldn't create object: @error, @serror" exit 1endif worked. Thanx for the quick reply!

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 640 anonymous users online.
Newest Members
ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder, M_Moore
17887 Registered Users

Generated in 0.052 seconds in which 0.022 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org