Page 1 of 1

George: return array in function

Posted: 08 Jun 2007, 14:03
by Mads Juul
is it possible to retun an array from a function if I code this:

Code: Select all

param none
	
	
	myArray = returnArray()
	
	tv_warn myArray[0]
	


Function returnArray()
	LOCAL array
	
	array[0] = "carl"
	array[1] = "barks"
	
	RETURN array
End  
I get this "myArray.0" WHERE I would expect "carl"

but if I dont declare the "array" variable local I can get what I want like this:

Code: Select all

param none
	
	
	returnArray()
	
	tv_warn array[0]
	


Function returnArray()
	
	array[0] = "carl"
	array[1] = "barks"
	
End  
Is this correct?

-mads[/code]

Re: George: return array in function

Posted: 08 Jun 2007, 14:28
by Hervé
Hi mads

No i'ts not possible to return an array

but you can return a parsable string

Code: Select all

Function returnArray() 
    return "one" "two" "x" "y" "z" 
End

result= returnArray()
Parse result array[0] array[1] array[2] xxxx

Posted: 08 Jun 2007, 14:30
by Mads Juul
thanx .-)