return array

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

return array

Postby als_santos » Jul 11, 2018 18:27

[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: 529
Joined: May 05, 2015 5:35
Location: Germany

Re: return array

Postby grindstone » Jul 11, 2018 21:24

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)

Return to “Beginners”

Who is online

Users browsing this forum: Majestic-12 [Bot] and 1 guest