Page 1 of 1 1
Topic Options
#88343 - 2002-09-28 10:04 PM Kixtart COM - Yet another way to silence COM calls
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Notice a few COM guys on the board. Was just tracing the Kixtart -> Forms COM interface and noticed (discovered) something interesting. Know how sometimes you want to silence a COM call because it returns an object - and your not interested in keeping a handle to that object so you silence it like this:

$ = $Excel.Sheets.Add

If you don't silence it - Kixtart will throw an exception anyway ... but with Forms, noticed that this syntax also works to silence the call.

$Excel.Sheets.Add.

Notice the period at the end of the statement ... I think I understand why this works (in Kixtart anyways). By specifying the period - your instructing Kixtart to take the object returned by this portion in brackets:

[$Excel.Sheets.Add].

and use it in the next nested operation - which in this case - doesn't exist [.(nothing)]

Basically what I think is going on here is that we are fooling Kixtart into think that a method or property call will be performed (after the period) - when in fact there isn't any .. so the Object handle that would normally roll into the next operation - gets discarded into the bit bucket ... heheee

[ 28. September 2002, 22:08: Message edited by: Shawn ]

Top
#88344 - 2002-09-28 10:28 PM Re: Kixtart COM - Yet another way to silence COM calls
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Ok - correction - the version of Kixtart I run at the office does (did) throw an exception ... 4.12 handles them nicely (yippie) just discards them to the bitbucket. 4.02 used to pipe the handle to the screen (?) ... think its finally handled properly in 4.12 so never mind.
Top
#88345 - 2002-09-30 02:43 PM Re: Kixtart COM - Yet another way to silence COM calls
Shawn Administrator Offline
Administrator
*****

Registered: 1999-08-13
Posts: 8611
Correction Correction:

opps - my orginal observation was correct after all. Kixtart 4.12 Beta 1 does not allow COM expressions (that return an object) to be unassigned (boo!):

So this works:

$obj = $object.property

But this throws an exception (if the property returns an object):

$object.property

If the property returns a string or a number - it gets piped to the console. But I thought that if it returned an object - that the string "[object]" got displayed on the console. Or better yet ... just discarded into the bit bucket.

Anyways - think we should suggest that discarding to the bitbucket should be implemented. But in terms of the orginal observation - this also silences these COM calls:

$object.property.

with the period at the end - not sure if this makes the code easier of more cryptic to read. Probably the latter.

-Shawn

Top
#88346 - 2002-10-02 12:40 AM Re: Kixtart COM - Yet another way to silence COM calls
Will Hetrick Offline
Hey THIS is FUN

Registered: 2001-10-02
Posts: 320
Loc: Harrisburg, PA USA
Hummm, Very interesting. I wonder if this is going to be one of those little checks that will dissapear in the future releases of Kix.

ie. $SystemSet = GetObject("winmgmts:{impersonationLevel=impersonate}!//$computer")
If Len($Systemset)=0 Exit EndIf
_________________________
You have at least 2 choices. Each choice changes your destiny. Choose wisely!

Top
#88347 - 2002-10-01 03:30 PM Re: Kixtart COM - Yet another way to silence COM calls
Sealeopard Offline
KiX Master
*****

Registered: 2001-04-25
Posts: 11165
Loc: Boston, MA, USA
I think the LEN is already gone in KiXtart 4.10/4.11+.
You'd rather do
'IF not @ERROR' or IF $objWhatever' or 'IF vartype($objWhatever) & 9'.
_________________________
There are two types of vessels, submarines and targets.

Top
Page 1 of 1 1


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

Who's Online
0 registered and 1046 anonymous users online.
Newest Members
Viginette, ManuvdWielNL, Sir_Barrington, batdk82, StuTheCoder
17888 Registered Users

Generated in 0.053 seconds in which 0.024 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