Android Question Meaning of on-line documentation not clear

PhilipBrown

Active Member
Licensed User
Longtime User
Can anyone explain the meaning of the following, which comes under Sub on the page
http://www.b4x.com/android/help/core.html

The return type declaration is different than other declarations as the array parenthesis follow the type and not the name (which does not exist in this case).

The full text is:

Sub

Declares a sub with the parameters and return type.
Syntax: Sub name [(list of parameters)] [As return-type]
Parameters include name and type.
The lengths of arrays dimensions should not be included.
Example:
Sub MySub (FirstName As String, LastName As String, Age As Int, OtherValues() As Double) As Boolean
...
End Sub
In this example OtherValues is a single dimension array.
The return type declaration is different than other declarations as the array parenthesis follow the type and not
the name (which does not exist in this case).
 

klaus

Expert
Licensed User
Longtime User
Let's take this example:
Sub MySub (FirstName As String, LastName As String, Age As Int, OtherValues() As Double) As Double()
In this example we have the declaration of an array in the Sub:
OtherValues() As Double here the parenthesis follow the variable name.
For the return array we have:
As Double() in this case the parenthesis follow the variable type.

Best regards.
 
Upvote 0

PhilipBrown

Active Member
Licensed User
Longtime User
Thank you Klaus. I've re-written this in the forthcoming book as follows:

Sub
Declares a sub with the parameters and return type. Syntax:
Sub name [(list of parameters)] [As return-type]
Any parameters which are given must include a name and type. You can pass an array as a parameter but it must be one-dimensional. The size of the dimension should not be included. Multi-dimensional arrays are not allowed. For example, a sub which requires a parameter iScores which is one-dimensional array would be declared as:
Sub dWeightedMean (strName As String, iScores() As Int) As Double
A sub can return an object of any type. It can also return a one-dimensional array. For example, a sub which returns an array of Double would be declared as:
Sub getArray (iCount As Int) As Double()
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…