Sign in to follow this  
Followers 0
chavv

SOLVED: weird problem with _ArrayDisplay and _IEWriteTableToArray

6 posts in this topic

#1 ·  Posted (edited)

SOLVED: see at bottom.

$oIE = _IECreate ($URL, 0, 0, 1, 0)
    $oTable = _IETableGetCollection ($oIE)
    $oTable = _IETableGetCollection($oIE, 1)
    $aTableData = _IETableWriteToArray ($oTable, True)

    ConsoleWrite ("number of elements: " & UBound($aTableData) & " " & $oTable.rows.length & @CRLF)

    _ArrayDisplay($aTableData)

    ConsoleWrite ("number of elements: " & UBound($aTableData) & " " & $oTable.rows.length & @CRLF)

    $oTable = _IETableGetCollection($oIE, 1)
    $aTableData = _IETableWriteToArray ($oTable, True)

    _ArrayDisplay($aTableData)

    ConsoleWrite ("number of elements: " & UBound($aTableData) & " " & $oTable.rows.length & @CRLF)

The referenced table has 95 rows. So the output to console should always be 95,95

But I get something different.

number of elements: 2 2

number of elements: 2 95

number of elements: 95 95

And needless to say, _ArrayDisplay shows different arrays :S, first time its empty

PS: A minute after I wrote it, thought occured to me, the page is automatically generated, maybe the moment the page is loaded, its not yet ready, scripts need time to execute.

Added sleep (1000) before first

$oTable = _IETableGetCollection($oIE, 1)

and - all 3 ConsoleWrites and 2 _ArrayDisplays showed what they should.

Maybe the topic should be removed, maybe not, this was completely unexpected for me.

Edited by chavv

Share this post


Link to post
Share on other sites



Thanks for posting your resolution.

In general, we do not want people to delete topics. A lot of the value of this site comes from being able to search for problems and see the resolutions. It annoys me and reduces the usefulness of the site when people just post "NVM, fixed it."

Cheers.

:huh2:


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

I had an identical problem and added the sleep(1000) to fix this problem.

Sometimes the site I'm using has a slow load and I get the error:

"C:\Program Files (x86)\AutoIt3\Include\IE.AU3 (1898) : ==> The requested action with this object has failed.:

Local $i_rows = $trs.length

Local $i_rows = $trs.length^ ERROR"

If I keep increasing the sleep time this error occurs less frequently, but speed is pretty important to me. Is there a way to force the script to wait until the page is completely loaded? I've tried using _IELoadWait($o_IE), where $o_IE is the an ie object for the page I am reading from, and it doesn't seem to do anything.

Sleep(1000)

$oTable = _IETableGetCollection($o_IE, 4)

$contents = _IETableWriteToArray($oTable)

Share this post


Link to post
Share on other sites

also I accidentally tried:

$oTable = _IETableGetCollection($o_IE, 4)

Sleep(2000)

$contents = _IETableWriteToArray($oTable)

first and it got the error:

C:\Program Files (x86)\AutoIt3\Include\IE.AU3 (1899) : ==> Array variable subscript badly formatted.:

Local $a_TableCells[$i_cols][$i_rows]

Local $a_TableCells[^ ERROR

which I think is very strange. Why would sleeping between getting $oTable and setting $contents cause this error?

Share this post


Link to post
Share on other sites

You can use _IEPropertyGet() on "busy", but there are no guarantees about scripts that continue running on the page after it is completely downloaded. If there is something running that is refreshing or recreating the table periodically, it would invalidate the $oTable reference.

:)


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

I'm not 100% sure what the problem was, but the the table I was updating from was not always done loading when the page finished loading.

I rewrote the _IETableWriteToArray to just copy the individual tr.cells to a file instead of writing to an array first. This fixed my problem.

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
Sign in to follow this  
Followers 0