Jump to content

Recommended Posts

Posted

As @Jon decided not to provide Array pointer, here's a small UDF to convert an array to a SafeArray and vice versa.
You can get the SafeArray.au3 from https://www.autoitscript.com/forum/topic/200660-variants-and-safearrays/

 

#include <Array.au3>
#include "SafeArray.au3"
#include "ArrayPointer UDF.au3"

__Example_0A()
Func __Example_0A()
    Local $Ary_0 = [[123456, 12.34, 'how are you?', -0.1234], [-100.001, 0.00009, "", 'Is it working?']]
    _ArrayDisplay( $Ary_0 )

    Local $t_SAobj
    Local $o_SAobj = __SafeArray_Dummy_Obj($t_SAobj)

    ;~~ Convert Array to SafeArray Pointer
    ;~~ Now you can pass the SafeArray pointer($psa) to any language, such as C, Python..........
    Local $psa
    $o_SAobj.Array_to_SafeArray($Ary_0, $psa)
    SafeArrayUnaccessData( $psa )

    ;~~ convert SafeArray Pointer to Array
    Local $p_Array_Copy
    $o_SAobj.SafeArray_to_Array($psa, $p_Array_Copy)
    SafeArrayDestroy($psa)      ;~~ delete the safeArray pointer when done.
    _ArrayDisplay( $p_Array_Copy )

    $o_SAobj = 0
    __Delete_SafeArray_ObjectFromTag( $t_SAobj )
EndFunc

 

ArrayPointer UDF.au3

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...