return array

New to FreeBASIC? Post your questions here.
Post Reply
als_santos
Posts: 4
Joined: Jun 28, 2018 20:44

return array

Post by als_santos »

[PtBr]
Como retornar uma array de uma função, ex:

[ENG]
How to retrieve an array from a function, ex:

Code: Select all

function test(x as integer, y as integer) as string
  dim return_(0 to 1) as string
  return_(0)=str(x)
  return_(1)=str(y)
  return return_
end function

dim a(0 to 1) as string
a = test(1, 2)
grindstone
Posts: 862
Joined: May 05, 2015 5:35
Location: Germany

Re: return array

Post by grindstone »

Code: Select all

Sub test(x As Integer, y As Integer, return_() As String)
	return_(0)=Str(x)
	return_(1)=Str(y)
End Sub

Dim return_(0 To 1) As String

test(1, 2, return_())
Print return_(0)
Print return_(1)

Sleep
The array has to be passed in the parameter list (arrays are always passed ByRef)
Post Reply