Page 1 of 1 1
Topic Options
#78844 - 2002-05-22 03:43 PM 4.10 RC1 - Error
Dean B. Offline
Fresh Scripter

Registered: 2002-02-04
Posts: 46
Loc: Allegan, MI USA
Gang,

I am getting an error when using the WMI Query UDF with RC1. The script works correctly with 4.02. Can anyone else verify this? Is there a fix or work-around?

Here is the link to WMI Query
_________________________
Dean

Top
#78845 - 2002-05-22 04:11 PM Re: 4.10 RC1 - Error
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Dean,

Its this line in the UDF:

If @Error = 0 and $objInstance <> ""

change it to this (note comment):

If @Error = 0 ;and $objInstance <> ""

still trying to figure why though.

-Shawn

[ 22 May 2002, 16:12: Message edited by: Shawn ]

Top
#78846 - 2002-05-22 04:19 PM Re: 4.10 RC1 - Error
Dean B. Offline
Fresh Scripter

Registered: 2002-02-04
Posts: 46
Loc: Allegan, MI USA
Shawn -

Thanks! That resolved the issue.
_________________________
Dean

Top
#78847 - 2002-05-22 04:22 PM Re: 4.10 RC1 - Error
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Still odd behaviour !?!??

seems to a bug ?

J.
_________________________



Top
#78848 - 2002-05-22 04:29 PM Re: 4.10 RC1 - Error
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Yeah, but you found a regression bug !

Run this - its ok:

break on

$user = getobject("WinNT://@DOMAIN/@USERID,user")

if $user and @error = 0
 ?"user found"
endif

exit 1


change the conditional to this:

if $user <> 0 and @error = 0


or this:

if $user <> "" and @error = 0


and the conditional doesn't resolve properly (it still works ok, but only because @error = 0), the tell-tale sign is that if you look at the DOS console, a the number 1 gets piped to the screen (the result of $user <> 0) - maybe Ruud just changed the behavior here, who knows.

-Shawn

p.s.

$user = 0

still seems to work ok though

[ 22 May 2002, 16:33: Message edited by: Shawn ]

Top
#78849 - 2002-05-22 05:04 PM Re: 4.10 RC1 - Error
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
It seems to be the case because the variable $user is an object and cannot be compared with string or integer variables.
_________________________
There are two types of vessels, submarines and targets.

Top
#78850 - 2002-05-22 05:33 PM Re: 4.10 RC1 - Error
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
I've noticed some other subtle "changes" with 4.10 as well, for example, AJH's MARRAY() UDF doesn't work anymore, but the ARRAY() function still does. Ruud has changed the types of expressions allowed inside array brackets.

-Shawn

Top
#78851 - 2002-05-22 05:55 PM Re: 4.10 RC1 - Error
Dean B. Offline
Fresh Scripter

Registered: 2002-02-04
Posts: 46
Loc: Allegan, MI USA
Shawn, Jens, etc -

So would changing the line from:

If @Error = 0 and $objInstance <> ""

to:

If @Error = 0 and vartype($objInstance) = 9

do the trick?

[ 22 May 2002, 18:03: Message edited by: Dean B. ]
_________________________
Dean

Top
#78852 - 2002-05-22 06:16 PM Re: 4.10 RC1 - Error
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
You want my two cents. Ì wouldn't even bother with any error checking in this particular circumstance. Your doing a FOR EACH IN enumeration, which has its own, builtin, error checking. The logic wouldn't even get inside the loop if you didn't already have a valid object pointer. Other than that, the @ERROR = 0 check is more than enough.

-Shawn

Top
#78853 - 2002-05-22 06:37 PM Re: 4.10 RC1 - Error
Jochen Administrator Offline
KiX Supporter
*****

Registered: 2000-03-17
Posts: 6380
Loc: Stuttgart, Germany
Ah, well trhe MARRAY() also fails with 4.02 ... I think because $MARRAY isn't yet defined as an array ?

using Square brackets inside square brackets does work well as definition is correct !
_________________________



Top
#78854 - 2002-05-22 10:15 PM Re: 4.10 RC1 - Error
Bryce Offline
KiX Supporter
*****

Registered: 2000-02-29
Posts: 3167
Loc: Houston TX
I always use vartype() for this type of error checking when using COM objects.

[code]
$user = getobject("WinNT:/" + @userid + ",user")
if vartype($user) <> 9 OR @error <> 0
? "Problem with the COM Object"
exit(@error)
endif

Bryce

Top
#78855 - 2002-05-22 11:16 PM Re: 4.10 RC1 - Error
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I have to agree with Bryce. I alwasy check whether an object has been created properly by using either VARTYPE($objVar)=9 or an IsObject($objVar) [VB SCript].

BTW, we should have some shortcut Is...() functions build into KiXtart, especially with the new number formats so we can check quickly for e.g. IsString, IsInteger, IsObject, IsArray, IsFloat and so on instead of the VarType(). Personal reason: I'm lazy and can't remember all the VarType return numbers, so I have to look it up in the manual (20 seconds each, 5 times a day, enough time to gulp down a cup of coffee, thus I'd prefer the coffee) [Wink]
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 857 anonymous users online.
Newest Members
JimDunn, fgarcia, Viginette, ManuvdWielNL, Sir_Barrington
17890 Registered Users

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