09-10-2014, 02:19 PM
If the macro will not use the array after mac:
Macro mac_t1
Function mac_t2
If the macro will use the array after mac, better use global variable:
Macro mac_t3
Function mac_t4
Macro mac_t1
int x(5)
ARRAY(int)* p._new ;;creates array in heap memory, not on stack
ARRAY(int)& y=p
y.create(2)
y[1]=6
mac "mac_t2" "" x &y ;;passes pointer to the array, let the function delete it when don't need/
function x ARRAY(int)&y
atend sub.AutoDeleteArray &y
out x
out y[1]
wait 2
#sub AutoDeleteArray
function ARRAY(int)*p
p._delete
out "array deleted"If the macro will use the array after mac, better use global variable:
Macro mac_t3
int x(5)
ARRAY(int)+ g_y
lock g_y
g_y.create(2)
g_y[1]=6
lock- g_y
mac "mac_t4" "" x
wait 2
lock g_y
out g_y[1]
lock- g_y