I am having trouble finding out how to write a "Declare Function" statement that specifies an array as a passed parameter. The following code runs ok but if I uncomment the "Declare Function two(... " line it gives me "error 55, type missmatch" at the "Function two(..." line later on.
How should I write the "Declare Function two(... )" line?
Declare Function one(As Double) As Double
Function one (x As Double) As Double
one = x
End Function
Print one(1)
' Declare Function two(As Integer, As Double) As Double
Function two ( n As Integer, x() As Double) As Double
two = x(n)
End Function
Dim As Double x2(3)
Dim As Integer nn = 2
x2(nn) = 2
Print two( nn, x2(nn) )
Sleep
Declare Function one(x As Double) As Double
Declare Function two(x() As Double,n As Integer) As Double
Function one (x As Double) As Double
one = x
End Function
Print one(1)
Function two (x() As Double,n as integer) As Double
two = x(n)
End Function
Dim As Double x2(3)
Dim As Integer n = 2
x2(n) = 2
Print two(x2(n),n)
Sleep
D.J.Peters, Thanks for that. To put the empty brackets in to specify an array needs any dummy variable name. The word array seems to work and makes the meaning obvious.
So simple.
Declare Function x ( Byref array() As Integer) as Integer
' the above gives a compile error 56 - illegal specification
Declare Function x ( array() As Integer) as Integer ' but this works OK
Is it possible to allow me to be explicit when passing arrays to functions and subs ?
Yeah, they aren't passed byref as other variables are, a reference to their descriptor is passed so it's more like "bydesc". Been that way since FB was created, as far as I know.