Sign in to follow this  
Followers 0
remowilliams

Catch error: Variable must be of type "Object"

5 posts in this topic

#1 ·  Posted (edited)

Hi Everyone,

After many hours searching for clues I decided to ask for your help.

I write an autoIt script for a website which behavior depends on the system load... there are ajax responses which may come many seconds later after interacting on the page (sometime after 30 seconds), buttons which should cause system activities by cklicking on them etc. But the page is sometime busy and does not make anything if I click too early.

But there is a processing image which appears always if the system is working and I have a function which tries to wait as long as this image is visible. This functions in the 95% of the cases but in the other 5% of the cases this image seems not to be found for a short time and the program execution will be aborted, the error message is always the following:

Variable must be of type "Object"

The related function looks like:

Func waitUntilProcessing($oIE, $time)
    Local $begin = TimerInit()
    $stillProcessing = 1
    While TimerDiff($begin) < $time AND $stillProcessing=1
        $x=_IEGetObjById($oIE,"WAIT_win0")
        If @error = 0 Then
            If $x.style.visibility = "hidden" Then
               $stillProcessing = 0
            EndIf
         EndIf
        sleep(100)
     WEnd
EndFunc

the error happens because of the variable $x.

this "If @error = 0 Then" does not help. The error references to the $x.style.visibility that the x should be an object.

this "if not $x.EOF Then" does not help also, in this case is this line the erronous line which kills the execution.

Okay the page will not be built sometime fast enough and maybe this image cannot be found. It doesn't matter. I want to wait until the image is visible or it does not exist yet. But no longer than the $time.

And I want to catch or just simple avoid this error.

How could I do this?

The testing of the possible fixes is not easy because the error comes occassionally.

Many thanks for the solution in advance!

Edited by remowilliams

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Use these to get around that...I notice those occur when looping.

_IEErrorHandlerRegister
_IEErrorHandlerDeRegister

Most any script using the _IE functions should have them.

Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Use these to get around that...I notice those occur when looping.

_IEErrorHandlerRegister
_IEErrorHandlerDeRegister

Most any script using the _IE functions should have them.

 

I have already found these functions by google but maybe I have not that AutoIt Version which knows these functions. I have only _IEErrorNotify but it does not help me.

Where can I update my version from or can I just simple download an. au3 file with these functions? My SciTE Version 3.4.1 help does not write anything about it.

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

That would probably do it, im 3.8.8.0 or something like that.  Not sure.  You can create your own error handler, and be just fine:

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

 

That would probably do it, im 3.8.8.0 or something like that.  Not sure.  You can create your own error handler, and be just fine:

Local $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite("err.number is: " & @TAB & $oError.number & @CRLF & _
            "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
            "err.description is: " & @TAB & $oError.description & @CRLF & _
            "err.source is: " & @TAB & $oError.source & @CRLF & _
            "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
            "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
            "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
            "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
            "err.retcode is: " & @TAB & $oError.retcode & @CRLF & @CRLF)
EndFunc   ;==>_ErrFunc

 

Thank you jdelaney, after many tests the error has not stopped the execution. I guess I reached my goal :guitar:

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