Posts: 26
	Threads: 8
	Joined: May 2014
	
	
 
	
	
		I need to pass array into a function but with another thread. how to do it?  way below doesn't work
Macro 
mac_t1 
int x(5)
ARRAY(int) y
y.create(2)
y[1]=6
mac "mac_t2" "" x y
Function 
mac_t2 
/
function x ARRAY(int)&y
out x
out y[1]
wait 10
 
 
	
	
	
		
	Posts: 12,239
	Threads: 144
	Joined: Dec 2002
	
	
 
	
	
		If the macro will not use the array after mac:
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 
mac_t2 
/
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
Function 
mac_t4 
/
function x ARRAY(int)&y
ARRAY(int)+ g_y
out x
lock g_y
out g_y[1]
g_y[1]=7
lock- g_y
wait 1
 
 
	
	
	
		
	Posts: 26
	Threads: 8
	Joined: May 2014