Jump to content

How Do I say "Object dot Scope"?


Recommended Posts

I have an object:

$oDiv

And I have an array, which contains the 'scope' (property) names of the object, like ID, className, innerText:

$aDivProperties

I would like to reference the object's properties using these variables, how would I do that?

For example, I would normally make these types of references:

$oDiv.ClassName

$oDiv.InnerText

$oDiv.ID

Instead I would like to call it from an Array element like:

$oDiv.$aDivProperties[$iCount]

But, this gives a syntax error, so how do I get around this?

Thanks

Local $aDivProperties [78]= ['ariaBusy','ariaChecked','ariaDisabled','ariaExpanded','ariaHaspopup', _
    'ariaHidden','ariaInvalid','ariaLevel','ariaMultiselect','ariaPosinset', _
    'ariaPressed','ariaReadonly','ariaRequired','ariaSecret','ariaSelected', _
    'ariaSetsize','attributes','blockDirection','canHaveChildren','canHaveHTML', _
    'className','clientHeight','clientLeft','clientTop','clientWidth', _
    'contentEditable','counterIncrement','counterReset','dataFld','dataFormatAs', _
    'dataSrc','dir','disabled','firstChild','hideFocus', _
    'id','innerHTML','innerText','isContentEditable','isDisabled', _
    'isMultiLine','isTextEdit','lang','language','lastChild', _
    'msBoxSizing','nextSibling','nodeName','nodeType','nodeValue', _
    'noWrap','offsetHeight','offsetLeft','offsetParent','offsetTop', _
    'offsetWidth','onOffBehavior','outerHTML','outerText','ownerDocument', _
    'parentElement','parentNode','parentTextEdit','previousSibling','readyState', _
    'recordNumber','role','scopeName','scrollHeight','scrollLeft', _
    'scrollTop','scrollWidth','sourceIndex','tabIndex','tagName', _
                'tagUrn','title','uniqueID']
    
    
    $oDivs = _IETagNameGetCollection ($oIE, "div")
    $iCount=0
    For $oDiv In $oDivs
        ConsoleWrite ($oDiv.$aDivProperties[$iCount] & @CRLF)
        $iCount+=1
    Next
Edited by litlmike
Link to comment
Share on other sites

@litlmike

I 'm sure I 've seen that question before a few years back ?!

But I can't tell if it was ever resolved, sorry.

Regards,

ptrex

Darn! I was thinking to myself, "oh, this is just one of those syntax issues that I don't understand because I am still just a wanna-be coder." Man, I thought this was going to be a quick solution! Thanks for the reply.
Link to comment
Share on other sites

In ActionScript and Javascript you can access objects multiple ways:

document.formName.fieldName.value

document.formName["fieldName"].value

document["formName"]["fieldName"].value

document.formName[variableName].value

Link to comment
Share on other sites

In ActionScript and Javascript you can access objects multiple ways:

document.formName.fieldName.value

document.formName["fieldName"].value

document["formName"]["fieldName"].value

document.formName[variableName].value

So are you implying that this cannot be done in AutoIt?

ConsoleWrite ($oLink.uniqueID & @CRLF);Example of what I want to say

Here are some attempts, based upon that direction, but they still seem to fail:

Local $aLinkProperties [49]= ['ariaChecked','ariaDisabled','ariaExpanded','ariaHaspopup','ariaHidden', _
                        'ariaInvalid','ariaLevel','ariaMultiselect','ariaPosinset','ariaPressed', _
                        'ariaReadonly','ariaRequired','ariaSecret','ariaSelected','ariaSetsize', _
                        'attributes','canHaveHTML','charset','disabled','firstChild', _
                        'href','hreflang','id','isContentEditable','isDisabled', _
                        'isMultiLine','isTextEdit','lastChild','name','nextSibling', _
                        'nodeName','nodeType','nodeValue','ownerDocument','parentElement', _
                        'parentNode','parentTextEdit','previousSibling','readyState','rel', _
                        'rev','role','scopeName','sourceIndex','tagName', _
                            'tagUrn','target','type','uniqueID']

$oIE = _IECreate ("www.Google.com", 1, 1, 1, 0)
$oLinks = _IELinkGetCollection ($oIE)
$iCount=0
For $oLink In $oLinks
    ConsoleWrite ($oLink.uniqueID & @CRLF) ;Example of what I want to say
    ConsoleWrite ($oLink.$aLinkProperties[$iCount] & @CRLF) ;This is what I want to say
    ConsoleWrite ($oLink.$aLinkProperties[$iCount] & @CRLF) ;Another Attempt
    ConsoleWrite ($oLink["aDivProperties"].$iCount & @CRLF) ;Another Attempt
    ConsoleWrite ($oLink["aDivProperties"]["$iCount"] & @CRLF) ;Another Attempt
    ConsoleWrite ($oLink[$aLinkProperties][$iCount] & @CRLF) ;Another Attempt
    ConsoleWrite ($oLink[$aLinkProperties].$iCount & @CRLF) ;Another Attempt
    $iCount+=1
Next
Edited by litlmike
Link to comment
Share on other sites

Perhaps this is what you are trying to do?

#include <IE.au3>
Local $aLinkProperties [49]= ['ariaChecked','ariaDisabled','ariaExpanded','ariaHaspopup','ariaHidden', _
                        'ariaInvalid','ariaLevel','ariaMultiselect','ariaPosinset','ariaPressed', _
                        'ariaReadonly','ariaRequired','ariaSecret','ariaSelected','ariaSetsize', _
                        'attributes','canHaveHTML','charset','disabled','firstChild', _
                        'href','hreflang','id','isContentEditable','isDisabled', _
                        'isMultiLine','isTextEdit','lastChild','name','nextSibling', _
                        'nodeName','nodeType','nodeValue','ownerDocument','parentElement', _
                        'parentNode','parentTextEdit','previousSibling','readyState','rel', _
                        'rev','role','scopeName','sourceIndex','tagName', _
                            'tagUrn','target','type','uniqueID']

$oIE = _IECreate ("www.Google.com", 1, 1, 1, 0)
$oLinks = _IELinkGetCollection ($oIE)
$iCount=0
For $oLink In $oLinks
    ConsoleWrite ($oLink.uniqueID & @CRLF) ;Example of what I want to say
    For $i=0 To 48
        Execute("ConsoleWrite(@TAB & '" & $aLinkProperties[$i] & ":' & $oLink." & $aLinkProperties[$i] & " & @CRLF)") ;Another Attempt
    Next
Next
Link to comment
Share on other sites

First off I would like to say...who's your daddy? Second, most of the attributes in your array won't apply to the $oLink object. Here is a list of the available properties for an AnchorElement object:

http://msdn.microsoft.com/en-us/library/bb149161.aspx

#include <IE.au3>
$oIE = _IECreate ("www.Google.com", 1, 1, 1, 0)
ConsoleWrite(ObjName($oIE) & @CRLF)
$oLinks = _IELinkGetCollection ($oIE)
ConsoleWrite(ObjName($oLinks) & @CRLF)
$iCount=0
For $oLink In $oLinks
    ConsoleWrite($oLink.getAttribute("uniqueID") & @CRLF)
    ConsoleWrite ($oLink.uniqueID & @CRLF) ;Example of what I want to say
    $iCount+=1
Next
Edited by weaponx
Link to comment
Share on other sites

Perhaps this is what you are trying to do?

First off I would like to say...who's your daddy?

Second, most of the attributes in your array won't apply to the $oLink object. Here is a list of the available properties for an AnchorElement object:

http://msdn.microsoft.com/en-us/library/bb149161.aspx

Wow! Nice from both of you! Thanks, I learned the following:

1) Who my real daddy is

2) That getAttribute exits

3) That @TAB exists

4) Execute has some usefulness

5) Some ActionScript and Javascript syntax

6) That there is always a solution to life's problems with AutoIt

@weaponx:

What is the difference between your link (1st one below) and this link (2nd one)? The second one is where I was going for the MSDN info.

http://msdn.microsoft.com/en-us/library/bb149161.aspx

http://msdn.microsoft.com/en-us/library/ms535173(VS.85).aspx

Link to comment
Share on other sites

Oops, I forgot to post this:

Local $aLinkProperties [49]= ['ariaChecked','ariaDisabled','ariaExpanded','ariaHaspopup','ariaHidden', _
                        'ariaInvalid','ariaLevel','ariaMultiselect','ariaPosinset','ariaPressed', _
                        'ariaReadonly','ariaRequired','ariaSecret','ariaSelected','ariaSetsize', _
                        'attributes','canHaveHTML','charset','disabled','firstChild', _
                        'href','hreflang','id','isContentEditable','isDisabled', _
                        'isMultiLine','isTextEdit','lastChild','name','nextSibling', _
                        'nodeName','nodeType','nodeValue','ownerDocument','parentElement', _
                        'parentNode','parentTextEdit','previousSibling','readyState','rel', _
                        'rev','role','scopeName','sourceIndex','tagName', _
                            'tagUrn','target','type','uniqueID']

$oIE = _IECreate ("www.Google.com", 1, 1, 1, 0)
$oLinks = _IELinkGetCollection ($oIE)
$iCount=0
For $oLink In $oLinks
    ConsoleWrite ("$oLink.href = " & $oLink.href & @CRLF) ;The link
    For $iCC=0 To UBound($aLinkProperties)-1
        ConsoleWrite(@TAB & $aLinkProperties[$iCC] & ":" & $oLink.getAttribute($aLinkProperties[$iCC]) & @CRLF) ;The link properties
    Next
    ConsoleWrite (@CRLF)
Next
Link to comment
Share on other sites

@weaponx:

What is the difference between your link (1st one below) and this link (2nd one)? The second one is where I was going for the MSDN info.

http://msdn.microsoft.com/en-us/library/bb149161.aspx

http://msdn.microsoft.com/en-us/library/ms535173(VS.85).aspx

The link you posted is a reference to the object formatting in raw html. The link I posted is what the html objects are parsed into by DOM.

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