George: return array in function

Please use this part to report bugs & errors, ask questions & "How to..."
Post Reply
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

George: return array in function

Post 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]
User avatar
Hervé
Site Admin
Posts: 3490
Joined: 08 Feb 2006, 17:00
Location: Metz France
Contact:

Re: George: return array in function

Post 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
User avatar
Mads Juul
Posts: 3992
Joined: 02 May 2007, 19:18

Post by Mads Juul »

thanx .-)
Post Reply