mIRC Homepage
Posted By: Chessnut Dispatching items in a collection (COM) - 25/07/10 06:51 PM
Another COM related question!

I know that $comval exists for enumerating through collections, but the problem I have is that I want to dispatch one item in particular in the collection.

In other words, does there exist something along the lines of $comval(a,1,dispatch* b) to dispatch the Nth item in a collection?

Thanks!
Not usre if it works, but have you tryed:
Code:
alias vid {
  var %a, %b, %c
  .comopen %a WbemScripting.SWbemLocator
  noop $com(%a,ConnectServer,3,dispatch* %b)
  noop $com(%b,ExecQuery,3,bstr*,select [I] from [P], dispatch* %c)
  noop $com(%c,...,dispatch* %d)
  ;do stuff with %d
  .comclose %d
  .comclose %c
  .comclose %b
  .comclose %a
}
WHere [I] is what you want to query, and [P] is what to query, then just use dispatch to %d.

As I said, not sure if it worx, but you can try smile
Posted By: hixxy Re: Dispatching items in a collection (COM) - 25/07/10 08:48 PM
This is another limitation in mIRC that we currently can't get around, however, a lot of objects offer an "item" method to retrieve an item from the collection. Depending on what you're using, you could probably do:

Code:
$com(object,item,3,int,<N>,dispatch* newobject)


Where <N> is the number in the collection you want to retrieve..

Obviously not all objects have this, but some do. The Windows Media Player object model is a prime example.
Posted By: Chessnut Re: Dispatching items in a collection (COM) - 25/07/10 09:24 PM
Bleurgh, mIRC's COM support is crap frown

Unfortunately I need to iterate through the collection to determine which item I want as I need one with a specific value assigned to a property of it.

FroggieDaFrog, I haven't seen that method before - I'll have a look into it.

Thanks both of you!
© mIRC Discussion Forums