Basic30 Language Reference
Function ... End Function Statements

Define a sub procedure.

[ { Public | Private | External }] [ RegParams ] Function name ( [parameters]) As type
   [statements]
   [Exit Function]
End
Function return Variable
name
Required name for this sub procedure.
parameters
Optional list of parameters to be passed to this procedure.
type
Required variable type for the function to return (Boolean, uByte, Byte, uInteger, Integer, uLong, Long)
[statements]
Optional block of statements that make up the body of the procedure.
return Variable
Required variable that holds the return value for this function.
Public
Optional keyword to define this procedure as a public member when compiling to a library file.  If omitted, private access is used.
Private
Optional keyword to define this procedure as a private member when compiling to a library file. If omitted, private access is used.
External
Optional keyword to mark this procedure as being defined in an external file which will be linked to the project after compiling.  If omitted, private access is used.
RegParams
Optional keyword to cause the compiler to pass parameters to this procedure using registers W0 - W7 instead of using the stack.  Parameters are loaded into registers from left to right starting with W0.  A 32 bit value will use two registers, with the first register being an even number.  If this option is used, an underscore character will be appended to the sub name to make it compatible with procedures and libraries generated by other compilers.

Notes:

 

Related Statements:

Exit Function
Exit this function, returning control back to the calling procedure.

Examples

Sub main()
      Dim a as uInteger
      a=init(10,4)
End Sub

Function add2(x as uInteger, y as uInteger)
     Dim z as uInteger
     z=x+y
End Function z
 

Also See: Sub .. End Sub