ThomasQ

How to read/count a Collection Object?

4 posts in this topic

Hi!

I'm extremely emberassed by my n00bness, but since I started using Autoit 6 months ago, I still got to a halt, when trying to use Collection Objects.

How do I count the number of Item's collected? And is there any way of looking in the collection object?

Many Thanks in advance

Thomas

Share this post


Link to post
Share on other sites



Do you mean like this using .count() ?

$Dict1 = ObjCreate("Scripting.Dictionary")

With $Dict1
  .Add ( "Item 1","10")
  .Add ("Item 2","20")
  .Add ("Item 3","30")
EndWith

MsgBox(0,"object.count",$Dict1.count())

GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF.

Share this post


Link to post
Share on other sites

Hi! Just got back from vacation, and started on my script again. But no, I meant an Collection object, like the one you get with the _IETableGetCollection function.

Thanks in advance!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

When you run _IETableGetCollection() the count is returned in @extended. See the help file. You might also get the count in a .length property, but I can't test to be sure right now.

:idea:

Edit: Back in Windows land, verified .length works:

#include <IE.au3>

$oIE = _IE_Example ("table")
$oTables = _IETableGetCollection ($oIE)
$iExtSav = @extended
$iLength = $oTables.length
MsgBox(64, "Test", "@extended = " & $iExtSav & "; .length = " & $iLength)

That's actually how the UDF gets it for @extended, though you have to look inside the call a little to see it:

Return SetError($_IEStatus_Success, $o_object.document.GetElementsByTagName("table" ).length,$o_object.document.GetElementsByTagName("table"))

:) Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now