Jump to content

How to read/count a Collection Object?


Recommended Posts

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

Link to comment
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.
Link to comment
Share on other sites

  • 4 weeks later...

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...