Jump to content

Noob Question re: Collection Elements


RoscoeT
 Share

Recommended Posts

Hello Board,

I just started to code some scripts with Autoit last night for the first time. I am pretty good at scripting in general with lots of PHP experience.

Searched google and the help files and not found what I am looking for so I am asking for help or a pointer to a specific doc.

If I have a function that returns a Collection how can I get information about the valid elements in that collection? Similar to the print_r() function in PHP or maybe the array_keys() function.

For example in the code below from examples I've seen, I know that $oLink.href is a valid "property" for each element in the $oLinks collection. But how could I see what other "property" names are valid? I know that many of the functions that return collections have some documentation. But suppose you needed to test it or had an undcoumented User Defined Function, how could you find this?

$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended

$GetHandle = WinGetHandle("Windows Internet Explorer")
WinSetState($GetHandle, "", @SW_MAXIMIZE)

For $oLink In $oLinks
; NEED HELP HERE....
NEXT

Much thanks in advance for any tips or help.

R

Link to comment
Share on other sites

I don't know if it helps but you could try something like this.

$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
$linkEl=""

$GetHandle = WinGetHandle("Windows Internet Explorer")
WinSetState($GetHandle, "", @SW_MAXIMIZE)

For $oLink In $oLinks
    If IsDeclared($oLink.href) Then $linkEl=$linkEl&"href: "&$oLink.href&@CRLF
    If IsDeclared($oLink.name) Then $linkEl=$linkEl&"name: "&$oLink.name&@CRLF
    ;...and so on
    Msgbox(0, "Elements of Link "&$oLink, $linkEl)
Next
Edited by Das Ami
Link to comment
Share on other sites

I don't know if it helps but you could try something like this.

$oLinks = _IELinkGetCollection ($oIE)
$iNumLinks = @extended
$linkEl=""

$GetHandle = WinGetHandle("Windows Internet Explorer")
WinSetState($GetHandle, "", @SW_MAXIMIZE)

For $oLink In $oLinks
    If IsDeclared($oLink.href) Then $linkEl=$linkEl&"href: "&$oLink.href&@CRLF
    If IsDeclared($oLink.name) Then $linkEl=$linkEl&"name: "&$oLink.name&@CRLF
    ;...and so on
    Msgbox(0, "Elements of Link "&$oLink, $linkEl)
Next

Thanks for the reply,

I guess what I am asking is... If you did not know that $oLink.name was called $oLink.name how would you know to check it with IsDeclared() ?

We know that $oLink has "properties" (unsure of the proper name) called "href" and "name" and various others. But were is that documented? And if its not documented how can you probe $oLInk to get the names of all its properties?

R

Link to comment
Share on other sites

They are called elements, hope this helps.

Well.. yeah.. but that's not what he's asking. Elements are the HTML stuff... what if other things return collections in autoit. I know in Powershell there are commands to probe for properties and methods of an object. Is there something equivalent in autoit?

(I'm curious now too).

Link to comment
Share on other sites

Well.. yeah.. but that's not what he's asking. Elements are the HTML stuff... what if other things return collections in autoit. I know in Powershell there are commands to probe for properties and methods of an object. Is there something equivalent in autoit?

(I'm curious now too).

Yes, exactly.

Thanks, can anyone answer this?

Link to comment
Share on other sites

What is the page, or an example of what you are trying to search and trying to find? If I understand what you want, you may just have to parse the page.

Cheers,

Brett

EDIT:

Also, please limit bumping to a 24 hour period.

Edited by BrettF
Link to comment
Share on other sites

What is the page, or an example of what you are trying to search and trying to find? If I understand what you want, you may just have to parse the page.

Cheers,

Brett

EDIT:

Also, please limit bumping to a 24 hour period.

Hi,

All I am trying to do is figure out how to determine what methods and properties an any object contains.

If I have a function, for example _IELinkGetCollection, that returns a collection of objects how can I know the valid properties and methods of each collection member?

In PHP it's print_r() or array_keys()

In the above example I know, from user examples that an object returned by _IELinkGetCollection() has the property href. But if I did not know that, how could I ever figure that out?

That is just an example for one object. How can I figure it out for any object? Not just that function. This is a general language problem and not specific to one piece of code.

Thanks,

R

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...