Sign in to follow this  
Followers 0
nooby

Passing an array parameter to a COM Object

5 posts in this topic

hi guys,

i'm writing a script that uses an object. one function i want to use has a parameter that needs to pass an array.

more info:

This parameter can be of type VT_ARRAY|VT_VARIANT, where each entry is a VT_BSTR, or VT_ARRAY|VT_BSTR

obviously, the stucture of the autoit array is not applicable, as it fails when trying something like this:

Local $array_parameter[5]
$obj.function($array_parameter)

after reading a little more on the function, i saw an article (i wasnt sure which scripting language they were writting in) and they said that the function works great like this:

string[] files = new string[] { ... };
object filesAsObject = (object)files;
Obj.function(ref filesAsObject);

How exactly can i pass this parameter type ? any suggestions

thanks

Share this post


Link to post
Share on other sites



This is one way...

Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
        For $x = 1 To $S_Files2Attach[0]
            $S_Files2Attach[$x] = _PathFull ($S_Files2Attach[$x])
            If FileExists($S_Files2Attach[$x]) Then
                $objEmail.AddAttachment ($S_Files2Attach[$x])
            Else
                $i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x]
                SetError(1)
                return 0
            EndIf
        Next

Also you might want to look at "with"

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

mm.. i don't think this is what i need..

i need to pass the whole array to the function

$objEmail.AddAttachment ($S_Files2Attach[$x]) ;passes the value of $array[$x]
;what i'm looking for is how to pass the entire array, so in this case, theoretically..
$objEmail.AddAttachment ($S_Files2Attach) ;passes the entire array (obviously does not work)

Share this post


Link to post
Share on other sites

There are only a few here that are really proficient with objects. I have played with them myself... just a little

here is an example of with

With $oGame
            .bgcolor = "#000000"
            .Movie = 'http://farm.addictinggames.com/D78AQSAKQLQWI9/1130.swf'
            .ScaleMode = 2
            .Loop = True
            .wmode = "Opaque"
        EndWith

other than these two ideas.... we need a more experienced person

Good Luck

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

I'm not too sure either, but as far as I know this should work with a C++ "array":

Global $myArray[10] = [ 10, 20, 3, 33, 24, 55, 76, 57, 38, 69 ]

$myRealArray = _CreateRealArray($myArray, "int")

; Then we can pass DLLStructGetPtr($myRealArray, "myarray") to the function?


Func _CreateRealArray($array, $type) ; "char*"
    $nLength = UBound($array) - 1
    $struct = DLLStructCreate($type & " myarray[" & $nLength & "];")
    For $i = 0 to $nLength
        DLLStructSetData($struct, "myarray", $array[$i], $i)
    Next
    
    Return $struct
EndFunc

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