Sign in to follow this  
Followers 0
MeInTheCorner

COM Object - passing array as VARIANT* - Error 80020009

2 posts in this topic

I'm trying to call a COM object function which requires an array of variants as argument. Passing an AutoIt array throws COM error 80020009 with no description. Since everything in autoit is a variant I assumed it would be np, but no.

Specifically, I'm trying to call FlashGet ("JetCar.Netscape" object)'s AddUrlList function which takes an array of urls / descriptions to open. I have it working in vbs, but I wanted to port to AutoIt to automate a few things the COM object does not expose. Anyways, here's the vbs code (start is just some fooling around with arguments, check the end...) Is it a bug in AutoIt, FlashGet or my script?

Dim args
Dim desc
Dim ref
desc=""
ref=""

If WScript.Arguments.Count > 1 Then
    ReDim args(WScript.Arguments.Count-1)
    For I = 0 To WScript.Arguments.Count-1
        args(I) = WScript.Arguments(I)
    Next
Else
    args = Split(WScript.Arguments(0), " ")
End If

Dim item
If UBound(args) < 1 Then
    item = True
ElseIf UBound(args) < 3 And NOT InStr(args(1), "://") Then
    item = True
Else
    item = False
End If

If item Then
    If UBound(args) > 0 Then desc = args(1)
    If UBound(args) > 1 Then ref = args(2)
    AddLink args(0), desc, ref
Else
    AddUrlList args
End If

Sub AddLink(ByVal Url, ByVal Desc, ByVal Referer)
    Set FlashGet = CreateObject("JetCar.Netscape")
    FlashGet.AddUrl Url, Desc, Referer
End Sub

Sub AddUrlList(ByVal UrlList)
    Dim Urls()
    If (InStr(UrlList(UBound(UrlList)), "--referrer=")) Then
        ReDim Urls(UBound(UrlList))
        reffull = UrlList(UBound(UrlList))
        Urls(0) = Right(reffull, Len(reffull)-11)
        For I = 0 To UBound(UrlList)-1
            Urls(I+1) = UrlList(I)
        Next
    Else
        ReDim Urls(UBound(UrlList)+1)
        Urls(0) = ref
        For I = 0 To UBound(UrlList)
            Urls(I+1) = UrlList(I)
        Next
    End If
    
    Set FlashGet = CreateObject("JetCar.Netscape")
    FlashGet.AddUrlList Urls
End Sub

And here is the au3 (v3.2.1):

#include <Array.au3>

If $CmdLine[0] == 0 Then Exit(0)

;MsgBox(0, "Args", "#: " & $CmdLine[0] & " Args: " & $CmdLineRaw)

Global $Args
If $CmdLine[0] == 1 Then
    $Args = StringSplit($CmdLine[1], " ")
Else
    Dim $Args[$CmdLine[0]]
    For $I = 0 To $CmdLine[0]-1
        $Args[$I] = $CmdLine[$I+1]
    Next
EndIf

Global $singleItem
If UBound($Args) == 1 Then
    $singleItem = true
ElseIf UBound($Args) < 3 AND NOT StringInStr($Args[1], "://") Then
    $singleItem = true
Else
    $singleItem = false
EndIf

Global $Description = ""
Global $Referrer = ""
If $singleItem Then
    If UBound($Args) > 1 Then $Description = $Args[1]
    If UBound($Args) > 2 Then $Referrer = $Args[2]
    AddLink($Args[0], $Description, $Referrer)
Else
    Dim $UrlList[1]
    $UrlList[0] = $Referrer
    For $I = 0 To UBound($Args)-1
        If StringInStr($Args[$I], "--referrer=") == 1 Then
            $UrlList[0] = StringTrimLeft($Args[$I], 11)
        Else
            _ArrayAdd($UrlList, $Args[$I])
        EndIf
    Next
;_ArrayDisplay($UrlList, "List")
    AddUrlList($UrlList)
EndIf

Func AddLink($Url, $Desc, $Referrer)
    Local $FlashGet = ObjCreate("JetCar.Netscape")
    $FlashGet.AddUrl($Url, $Desc, $Referrer)
EndFunc

Func AddUrlList(ByRef $List)
    Global $MyList[UBound($List)]
    For $I = 0 To UBound($List)-1
        $MyList[$I] = $List[$I]
    Next
;_ArrayDisplay($MyList, "List")
    
    Global $oMyError = ObjEvent("AutoIt.Error", "ErrFunc")
    Global $FlashGet = ObjCreate("JetCar.Netscape")
    
    $FlashGet.AddUrlList($MyList)
EndFunc

Func ErrFunc()
   Local $HexNumber = Hex($oMyError.number,8)
   Local $Description = StringStripWS($oMyError.description, 3)
   Msgbox(0, "COM Error 0x" & $HexNumber,"A COM Error occurred !" & @CRLF & @CRLF & _
                "Number: " & $HexNumber & @CRLF & _
                "Line: " & $oMyError.scriptline & @CRLF & _
                "Description: " & $Description & @CRLF & _
                "WinDescription: " & $oMyError.windescription )
   SetError(1)
Endfunc

Notice I tried to recreate the array in function, tried in Global scope, etc. Nothing does it. Any help would be greatly apreciated.

Share this post


Link to post
Share on other sites



Still no fix. Still no help?

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